Commit 31854732 authored by Nicolas Wavrant's avatar Nicolas Wavrant

fixup! erp5_web_renderjs_ui: let gadget know the language in which the interface is rendered

parent eab8e0c6
......@@ -3,24 +3,18 @@
(function (document, window, RSVP, rJS, translation_data) {
"use strict";
function getSelectedLanguage(gadget) {
var queue = new RSVP.Queue();
function getSelectedLanguage(gadget, callback) {
if (!gadget.state.language) {
queue.push(function () {
return gadget.getSettingList([
"selected_language",
"default_selected_language"
]);
})
])
.push(function (result_list) {
gadget.state.language = result_list[0] || result_list[1];
return callback(gadget.state.language);
});
}
return queue.push(function () {
return gadget.state.language;
});
return callback(gadget.state.language);
}
function translate(string, gadget) {
......@@ -126,8 +120,7 @@
}
function promiseTranslateList(gadget, string_list, only_first) {
return getSelectedLanguage(gadget)
.push(function () {
return getSelectedLanguage(gadget, function () {
return translateList(gadget, string_list, only_first);
});
}
......@@ -135,7 +128,9 @@
rJS(window)
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareMethod('getSelectedLanguage', function () {
return getSelectedLanguage(this);
return getSelectedLanguage(this, function (language) {
return language;
});
})
.declareMethod('getTranslationList', function (string_list) {
return promiseTranslateList(this, string_list);
......@@ -146,8 +141,7 @@
.declareMethod('translateHtml', function (string) {
var gadget = this;
return getSelectedLanguage(gadget)
.push(function (language) {
return getSelectedLanguage(gadget, function () {
return translateHtml(string, gadget);
});
});
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>980.48186.1859.61969</string> </value>
<value> <string>981.1053.43706.60842</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1577760469.24</float>
<float>1578453690.65</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment