[FIX] web : translate all content in customer preview

When we go into customer preview of a quotation for example and change the language different than English (to fr_BE for example)
we see that some of the content isn't translated  and still displaying in english.

Steps to reproduce the error :
1-Install sales and website app
2-Create a quotation for a customer and just save it don't confirm it.
3-Go to customer preview
4-Change the language to fr_BE
5-Click on "signer & payer"
6-You can see that it still display 'Full Name' in english and also some other terms

The origin of the problem is that all the parts that were rendered via a t-call gets rendered in english.
I investigated the problem and it turns out that the language code for the _t is alwyas english(https://github.com/odoo/odoo/blob/06719a84c52c7a97487b7ee0bef3bbe166d5b502/addons/portal/static/src/js/portal_signature.js#L45)
The problem is that the user_context.lang is always undefined here (https://github.com/odoo/odoo/blob/06719a84c52c7a97487b7ee0bef3bbe166d5b502/addons/web/static/src/legacy/js/core/session.js#L201)
As a solution I copied the code from 15.0 which was working fine (https://github.com/odoo/odoo/blob/4fa2dbcaf777c23758519ab0feb9707a7592cd6b/addons/web/static/src/legacy/js/core/session.js#L199-L209).

opw-3192666
.

closes odoo/odoo#125638

X-original-commit: 441c94270a4935d2b0b67a9f8201fcba9d15d957
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
This commit is contained in:
Mahdi Cheikh Rouhou (macr)
2023-06-19 19:17:00 +02:00
parent 640332df35
commit 0a89e70e5b
@@ -197,7 +197,13 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
});
},
load_translations: function (modules=null) {
return _t.database.load_translations(this, modules, this.user_context.lang, this.translationURL);
var lang = this.user_context.lang
var html = document.documentElement
, htmlLang = html.getAttribute('lang');
if (!this.user_context.lang && htmlLang) {
lang = htmlLang.replace('-', '_');
}
return _t.database.load_translations(this, modules, lang, this.translationURL);
},
load_js: function (files) {
var self = this;