From 3de9f5953d84f579dc1a4f5ed52e263a1e2c932f Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Thu, 15 Apr 2021 11:24:24 +0000 Subject: [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) Signed-off-by: Anh Thao PHAM --- addons/web/static/src/js/core/session.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/core/session.js') 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); }, -- cgit v1.2.3