[saem-devel] [PATCH saem_ref] Force language to french in http-negociation mode

Philippe Pepiot philippe.pepiot at logilab.fr
Tue Feb 21 18:15:40 CET 2017



On 02/21/2017 05:49 PM, Sylvain Thénault wrote:
> Le 21/02/2017 à 17:43, Philippe Pepiot a écrit :
>> On 02/21/2017 05:27 PM, Denis Laxalde wrote:
>>
>>> Philippe Pepiot a écrit :
>>>> # HG changeset patch
>>>> # User Philippe Pepiot <philippe.pepiot at logilab.fr>
>>>> # Date 1487693269 -3600
>>>> #      Tue Feb 21 17:07:49 2017 +0100
>>>> # Node ID a3f7ef5825c98aeb695a3404e337c5e34ef39229
>>>> # Parent  ce2a74e6ac634a14e58c61205d0386db904853c6
>>>> # Available At https://hg.logilab.org/review/cubes/saem_ref
>>>> #              hg pull https://hg.logilab.org/review/cubes/saem_ref
>>>> -r a3f7ef5825c9
>>>> # Tested at https://jenkins.logilab.org/job/cubicweb-saem_ref/82/
>>>> Force language to french in http-negociation mode
>>>>
>>>> diff --git a/cubicweb_saem_ref/site_cubicweb.py
>>>> b/cubicweb_saem_ref/site_cubicweb.py
>>>> --- a/cubicweb_saem_ref/site_cubicweb.py
>>>> +++ b/cubicweb_saem_ref/site_cubicweb.py
>>>> @@ -25,6 +25,7 @@ from cubicweb import cwvreg, _
>>>>   from cubicweb.cwconfig import register_persistent_options
>>>>   from cubicweb.uilib import PRINTERS
>>>>   from cubicweb.entity import Entity
>>>> +from cubicweb.web import request
>>>>
>>>>   from cubes.skos import rdfio
>>>>   from cubes.skos.ccplugin import ImportSkosData
>>>> @@ -204,3 +205,8 @@ def is_hook_category_activated(self, cat
>>>>       if self._hooks_mode is session.HOOKS_DENY_ALL:
>>>>           return category in self._hooks_categories
>>>>       return category not in self._hooks_categories
>>>> +
>>>> +
>>>> + at monkeypatch(request._CubicWebRequestBase)
>>>> +def negotiated_language(self):
>>>> +    return 'fr'
>>>
>>> Please explain why we'd need this.
>> Because currently cubicweb with language-mode=http-negociation
>> (default) seems to ignore user preferences for language.
>> So I could not get a french translation on my browser configured in
>> english.
>> Also we have missing translations in english for 'foo_plural' etc.
>> Since we are talking to french audience, let's force french
>> translation at leat until things get fixed in cubicweb.
>>
> we might add a comment above the monkey-patch explaining this is
> currently the easiest way to force the language of a cw instance.
>
I sent a V2

-- 
Philippe Pepiot
https://www.logilab.fr



More information about the saem-devel mailing list