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.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
2 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.
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7620 r7678  
    3636
    3737class SIRPUtils(grok.GlobalUtility):
    38     """A collection of methods subject to customization.
     38    """A collection of parameters and methods subject to customization.
    3939    """
    4040    grok.implements(ISIRPUtils)
     41    # This the only place where we define the portal language
     42    # which is used for the translation of system messages
     43    # (e.g. object histories).
     44    PORTAL_LANGUAGE = 'en'
    4145
    4246    def sendContactForm(self,from_name,from_addr,rcpt_name,rcpt_addr,
Note: See TracChangeset for help on using the changeset viewer.