From c15d698f84d77c34393d33dbe492d44694619010 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 17 Sep 2014 15:05:01 +0200 Subject: [PATCH] =?utf8?q?Pr=C3=A9f=C3=A9rences=20linguistiques=20enregist?= =?utf8?q?r=C3=A9es=20dans=20les=20donn=C3=A9es=20utilisateur=20et=20utili?= =?utf8?q?s=C3=A9es=20en=20priorit=C3=A9=20(par=20rapport=20au=20pr=C3=A9f?= =?utf8?q?=C3=A9rences=20du=20navigateur).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- overrides.zcml | 6 ++++++ skins/custom_generic/personalize_form.pt | 10 ++++++++++ userlanguages.py | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 userlanguages.py diff --git a/overrides.zcml b/overrides.zcml index bf37e72..3c01665 100644 --- a/overrides.zcml +++ b/overrides.zcml @@ -15,4 +15,10 @@ Products.CMFCore.interfaces.ICatalogTool" provides="Products.CMFCore.interfaces.IIndexableObject" factory=".catalog_adapters.PlinnIndexableObjectWrapper" /> + + diff --git a/skins/custom_generic/personalize_form.pt b/skins/custom_generic/personalize_form.pt index 6836348..149f1dc 100755 --- a/skins/custom_generic/personalize_form.pt +++ b/skins/custom_generic/personalize_form.pt @@ -41,6 +41,16 @@ + + Preferred languages + + +
+
Please enter language codes separated by spaces.
+
+ +
diff --git a/userlanguages.py b/userlanguages.py new file mode 100644 index 0000000..8103d15 --- /dev/null +++ b/userlanguages.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from zope.publisher.browser import BrowserLanguages +from Products.CMFCore.utils import getUtilityByInterfaceName + +class AuthenticatedUserLanguages(BrowserLanguages): + + def getPreferredLanguages(self) : + mtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMembershipTool') + if mtool.isAnonymousUser() : + return super(AuthenticatedUserLanguages, self).getPreferredLanguages() + else : + m = mtool.getAuthenticatedMember() + userLangs = m.getProperty('preferred_languages', []) + return userLangs or super(AuthenticatedUserLanguages, self).getPreferredLanguages() -- 2.20.1