diff options
| author | Anh Thao Pham (pta) <pta@odoo.com> | 2021-04-15 11:24:24 +0000 |
|---|---|---|
| committer | Anh Thao Pham (pta) <pta@odoo.com> | 2021-04-15 13:07:02 +0000 |
| commit | 3de9f5953d84f579dc1a4f5ed52e263a1e2c932f (patch) | |
| tree | 7a686bd5665e5148f8a4820c8fb689a59443bac7 /addons/web/static/src/js | |
| parent | e9538d9cee092e034b85187a2eae857349f42ce7 (diff) | |
[FIX] web: do not use default en_US lang when loading translations from session
When loading translations from Session, if no lang is defined in context or html,
it is loading translations of en_US lang by default.
No default should be used to fallback on the language of the current user.
opw-2501708
closes odoo/odoo#69318
X-original-commit: a93a0a33c7447505403097c7ba0707d55d252e64
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/core/session.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index ae31b95696d..c8a879e217a 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -211,13 +211,16 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { }); }, load_translations: function () { + var lang = this.user_context.lang /* We need to get the website lang at this level. The only way is to get it is to take the HTML tag lang Without it, we will always send undefined if there is no lang in the user_context. */ var html = document.documentElement, - htmlLang = (html.getAttribute('lang') || 'en_US').replace('-', '_'), - lang = this.user_context.lang || htmlLang; + htmlLang = html.getAttribute('lang'); + if (!this.user_context.lang && htmlLang) { + lang = htmlLang.replace('-', '_'); + } return _t.database.load_translations(this, this.module_list, lang, this.translationURL); }, |
