Ignore:
Timestamp:
22 Feb 2012, 11:37:37 (13 years ago)
Author:
Henrik Bettermann
Message:

Let's define the portal language in our global utility SIRPUtils.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/language.py

    r7676 r7678  
    1818
    1919import grokcore.component
     20from zope.component import getUtility
    2021from zope.publisher.interfaces.browser import IBrowserRequest
    2122from zope.i18n.interfaces import IUserPreferredLanguages
    2223from waeup.sirp.configuration import ConfigurationContainer
     24from waeup.sirp.interfaces import ISIRPUtils
    2325
    2426class SIRPLanguage(grokcore.component.Adapter):
    25     """Set portal and preferred languages"""
     27    """Set preferred languages"""
    2628    grokcore.component.context(IBrowserRequest)
    2729    grokcore.component.implements(IUserPreferredLanguages)
    28     # This the only place where we define the portal language
    29     # which is used for the translation of system messages
    30     # (e.g. object histories).
    31     portal_language = 'en'
    3230
    3331    def getPreferredLanguages(self):
     32        portal_language = getUtility(ISIRPUtils).PORTAL_LANGUAGE
     33
    3434        # This an adapter for the request, so self.context is the request.
    3535        request = self.context
    3636
    3737        # Extract the preferred language from a cookie:
    38         lang = request.cookies.get('sirp.language', self.portal_language)
     38        lang = request.cookies.get('sirp.language', portal_language)
    3939
    4040        # According to IUserPreferredLanguages, we must return a list.
Note: See TracChangeset for help on using the changeset viewer.