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

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


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1487693269 -3600
#      Tue Feb 21 17:07:49 2017 +0100
# Node ID 5cea7d490d797156b648d02e3c87afeaead4193a
# Parent  ce2a74e6ac634a14e58c61205d0386db904853c6
# Available At https://hg.logilab.org/review/cubes/saem_ref
#              hg pull https://hg.logilab.org/review/cubes/saem_ref -r 5cea7d490d79
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,11 @@ 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):
+    # Force language to fr since in http-negociation mode there is no way to
+    # force french language with a browser configured in english.
+    # This is currently the easiest way to force the language of an instance.
+    return 'fr'



More information about the saem-devel mailing list