from zope.publisher.browser import BrowserLanguages from Products.iva.interfaces import IUserManager from zope.component import getUtility from AccessControl import getSecurityManager from zope.component import ComponentLookupError class UILanguage(BrowserLanguages): def getPreferredLanguages(self): langs = super(UILanguage, self).getPreferredLanguages() sm = getSecurityManager() if str(sm.getUser()) == 'Anonymous User': return langs um = None try: um = getUtility(IUserManager) except ComponentLookupError: return langs u = None try: u = um.get_user_info(str(sm.getUser())) except KeyError: pass if not u: return langs if not u.kasKeelBrauserist(): ul = u.get_language() if ul: langs.insert(0, ul) return langs