From 55eb75d949202da9e2d7940b64d92964b2021962 Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Thu, 15 Apr 2021 11:24:24 +0000 Subject: [PATCH] [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#69336 X-original-commit: 0b9ab4efcf66d4c5099a9f33d2fb1b4dd814eb5c 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(-) diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index b9ff01c7dac..66010f21eb3 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -195,13 +195,16 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { }); }, load_translations: function (modules=null) { + 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, modules, lang, this.translationURL); },