diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-07-27 11:02:28 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-07-27 14:31:42 +0200 |
| commit | 16f0e5031835765dcfed84a250119ea0f15eb30a (patch) | |
| tree | 58263771eb0882e4ea580bab39953ca7340198e3 /addons/web/static/src/js | |
| parent | 519ed866d7fb3cf6fe0078f2ee2c27d96a46dd9b (diff) | |
[REF] web, web_editor, website: always let session load translations
Before this commit, the session object was responsible for loading the
translations in the backend only. There was then ugly code in web_editor
(which is also loaded in backend...) which was doing "if frontend then
load translations by myself". This code was also translating templates
while this is the qweb object's job. Now session is always responsible
for loading translation.
Note: the session object should be refactored/split.
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/core/session.js | 13 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/translation.js | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index c98ff7fbe9a..c21a855bab5 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -87,14 +87,19 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { * Init a session, reloads from cookie, if it exists */ session_init: function () { + var self = this; var def = this.session_reload(); - if (this.is_frontend) return def; - var self = this; + if (this.is_frontend) { + return def.then(function () { + return self.load_translations(); + }); + } + return def.then(function () { var modules = self.module_list.join(','); var deferred = self.load_qweb(modules); - if(self.session_is_valid()) { + if (self.session_is_valid()) { return deferred.then(function () { return self.load_modules(); }); } return $.when( @@ -217,7 +222,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { }); }, load_translations: function () { - return _t.database.load_translations(this, this.module_list, this.user_context.lang); + return _t.database.load_translations(this, this.module_list, this.user_context.lang, this.translationURL); }, load_css: function (files) { var self = this; diff --git a/addons/web/static/src/js/core/translation.js b/addons/web/static/src/js/core/translation.js index f2bad0db4ee..fae44774a07 100644 --- a/addons/web/static/src/js/core/translation.js +++ b/addons/web/static/src/js/core/translation.js @@ -57,11 +57,12 @@ var TranslationDataBase = Class.extend(/** @lends instance.TranslationDataBase# it will default to all the modules installed in the current database. @param {Object} [lang] lang The language. If not specified it will default to the language of the current user. + @param {string} [url='/web/webclient/translations'] @returns {jQuery.Deferred} */ - load_translations: function(session, modules, lang) { + load_translations: function(session, modules, lang, url) { var self = this; - return session.rpc('/web/webclient/translations', { + return session.rpc(url || '/web/webclient/translations', { "mods": modules || null, "lang": lang || null }).done(function(trans) { |
