From be5950e429e40e79ccc1330a1f6a79cf71d48a5b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 16 Nov 2017 13:36:55 +0100 Subject: [PATCH] [FIX] web_planner: use user language on frontend The web planner specified no language for frontend so the website planner on the frontend was never translated. This commit add a specialized fallback for this use case so the planner on the website is in the language of the current user. The code is the same that get_context from web_editor.base but requiring that would possibly adds delays (for dom_ready) that we don't want. note: this is for 9.0 up to not including 11.0, in 11.0 another solution is used and in master a bigger change is being worked on. opw-781727 fixes #20829 closes #21004 --- addons/web_planner/static/src/js/web_planner_common.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web_planner/static/src/js/web_planner_common.js b/addons/web_planner/static/src/js/web_planner_common.js index ad27739f2c5..1e230a4f830 100644 --- a/addons/web_planner/static/src/js/web_planner_common.js +++ b/addons/web_planner/static/src/js/web_planner_common.js @@ -66,10 +66,17 @@ var PlannerDialog = Widget.extend({ */ willStart: function() { var self = this; + var context = session.user_context; + // fallback context for frontend + if(_.isEmpty(context)) { + context = { + lang: (document.documentElement.getAttribute('lang')||'').replace('-', '_'), + }; + } var res = this._super.apply(this, arguments).then(function() { return (new Model('web.planner')).call('render', [self.planner.view_id[0], self.planner.planner_application], - {context: session.user_context}); + {context: context}); }).then(function(template) { self.$res = $(template); });