Closed simahawk closed 3 years ago
Would be nice if customers can set their language via their account form in locomotive.
On locomotive available langs come from: https://github.com/shopinvader/odoo-shopinvader/blob/12.0/shopinvader_locomotive/component/shopinvader_site_export_mapper.py#L57 So we could:
1. loco: add a selection field on registration form and account form by default: current lang selected. If you don't need it, just hide it or maybe we hide it automatically if you have only one lang
:+1:
2. odoo: accept `lang` as customer param. This could be done any time - even now w/out the change on locomotive side - as the default would come from current ctx lang, no?
You're right. easy change to introduce without breaking existing installation. Currently the default come from the ctx, if the customer has already selected the right language into the site, the lang will be correctly filled into the partner info. This change will just allows the "force" the language into the customer information.
3. loco optional step 2: based on customer lang we can redirect users to their own lang on login -> overrides browser lang behavior
:+1:
Side note / side question: AFAIS the only place where the lang is taken in consideration on odoo side is this: https://github.com/OCA/rest-framework/blob/c4360825d4f4b9f037438194dd4ad7a133133cf2/base_rest/http.py#L119
Basically the REST API takes care of setting the language for the whole request. Correct?
Yes, based on the http header.... By default this header is filled by the browser based on you language preference defined into the settings. If I'm not wrong, locomotive fill this header with the lang selected by the customer. https://github.com/shopinvader/locomotive-shopinvader/blob/v4.0.x/lib/shop_invader/services/erp_service.rb#L185 Unfortunately, @sebastienbeau introduced a typo one month ago breaking the logic... https://github.com/shopinvader/locomotive-shopinvader/pull/52
point 2 implemented here https://github.com/shopinvader/odoo-shopinvader/pull/474
point 1 and 3 will be done by @thibaultrey in the template (maybe w/ some help on Ruby side by @sebastienbeau ).
Would be nice if customers can set their language via their account form in locomotive.
On locomotive available langs come from: https://github.com/shopinvader/odoo-shopinvader/blob/12.0/shopinvader_locomotive/component/shopinvader_site_export_mapper.py#L57 So we could:
loco: add a selection field on registration form and account form by default: current lang selected. If you don't need it, just hide it or maybe we hide it automatically if you have only one lang
odoo: accept
lang
as customer param. This could be done any time - even now w/out the change on locomotive side - as the default would come from current ctx lang, no?loco optional step 2: based on customer lang we can redirect users to their own lang on login -> overrides browser lang behavior
To me is a nice generic improvement. @lmignon @sebastienbeau What do you think? CC @thibaultrey
Side note / side question: AFAIS the only place where the lang is taken in consideration on odoo side is this: https://github.com/OCA/rest-framework/blob/c4360825d4f4b9f037438194dd4ad7a133133cf2/base_rest/http.py#L119
Basically the REST API takes care of setting the language for the whole request. Correct?