1 # -*- coding: utf-8 -*-
2 from zope
.publisher
.browser
import BrowserLanguages
3 from Products
.CMFCore
.utils
import getUtilityByInterfaceName
4 from zope
.component
.interfaces
import ComponentLookupError
6 class AuthenticatedUserLanguages(BrowserLanguages
):
8 def getPreferredLanguages(self
) :
10 mtool
= getUtilityByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
11 except ComponentLookupError
:
12 return super(AuthenticatedUserLanguages
, self
).getPreferredLanguages()
13 if mtool
.isAnonymousUser() :
14 return super(AuthenticatedUserLanguages
, self
).getPreferredLanguages()
16 m
= mtool
.getAuthenticatedMember()
17 userLangs
= m
.getProperty('preferred_languages', [])[:]
18 return userLangs
or super(AuthenticatedUserLanguages
, self
).getPreferredLanguages()