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 @@ ...@@ -3,24 +3,18 @@
(function (document, window, RSVP, rJS, translation_data) { (function (document, window, RSVP, rJS, translation_data) {
"use strict"; "use strict";
function getSelectedLanguage(gadget) { function getSelectedLanguage(gadget, callback) {
var queue = new RSVP.Queue();
if (!gadget.state.language) { if (!gadget.state.language) {
queue.push(function () { return gadget.getSettingList([
return gadget.getSettingList([
"selected_language", "selected_language",
"default_selected_language" "default_selected_language"
]); ])
}) .push(function (result_list) {
.push(function (result_list) { gadget.state.language = result_list[0] || result_list[1];
gadget.state.language = result_list[0] || result_list[1]; return callback(gadget.state.language);
}); });
} }
return callback(gadget.state.language);
return queue.push(function () {
return gadget.state.language;
});
} }
function translate(string, gadget) { function translate(string, gadget) {
...@@ -126,8 +120,7 @@ ...@@ -126,8 +120,7 @@
} }
function promiseTranslateList(gadget, string_list, only_first) { function promiseTranslateList(gadget, string_list, only_first) {
return getSelectedLanguage(gadget) return getSelectedLanguage(gadget, function () {
.push(function () {
return translateList(gadget, string_list, only_first); return translateList(gadget, string_list, only_first);
}); });
} }
...@@ -135,7 +128,9 @@ ...@@ -135,7 +128,9 @@
rJS(window) rJS(window)
.declareAcquiredMethod("getSettingList", "getSettingList") .declareAcquiredMethod("getSettingList", "getSettingList")
.declareMethod('getSelectedLanguage', function () { .declareMethod('getSelectedLanguage', function () {
return getSelectedLanguage(this); return getSelectedLanguage(this, function (language) {
return language;
});
}) })
.declareMethod('getTranslationList', function (string_list) { .declareMethod('getTranslationList', function (string_list) {
return promiseTranslateList(this, string_list); return promiseTranslateList(this, string_list);
...@@ -146,10 +141,9 @@ ...@@ -146,10 +141,9 @@
.declareMethod('translateHtml', function (string) { .declareMethod('translateHtml', function (string) {
var gadget = this; var gadget = this;
return getSelectedLanguage(gadget) return getSelectedLanguage(gadget, function () {
.push(function (language) { return translateHtml(string, gadget);
return translateHtml(string, gadget); });
});
}); });
}(document, window, RSVP, rJS, translation_data)); }(document, window, RSVP, rJS, translation_data));
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>980.48186.1859.61969</string> </value> <value> <string>981.1053.43706.60842</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1577760469.24</float> <float>1578453690.65</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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