blob: 14e54c7a3c81e0efcc52127e7ed3c26e2e0a2a1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
( function ( $, mw ) {
'use strict';
/**
* This class can save translation to translation stash.
*
* @since 2013.10
*/
var TranslationStashStorage = function () {
// No-op for now. Could take api module as param for example.
};
TranslationStashStorage.prototype = {
/**
* Save the translation.
*
* @param {string} title The title of the page including language code
* to store the translation.
* @param {string} translation The translation of the message
* @return {jQuery.Promise}
*/
save: function ( title, translation ) {
var api = new mw.Api();
// Change to csrf when support for MW 1.25 is dropped
return api.postWithToken( 'edit', {
action: 'translationstash',
subaction: 'add',
title: title,
translation: translation
} ).promise();
},
/**
* Get the current users translations.
*
* @return {jQuery.Promise}
*/
getUserTranslations: function ( user ) {
var api = new mw.Api();
// Change to csrf when support for MW 1.25 is dropped
return api.postWithToken( 'edit', {
action: 'translationstash',
subaction: 'query',
username: user
} ).promise();
}
};
mw.translate = mw.translate || {};
mw.translate.TranslationStashStorage = TranslationStashStorage;
}( jQuery, mediaWiki ) );
|