Beispiel #1
0
    def setUp(self):
        psetup = PlacefulSetup()
        self.sm = psetup.setUp(True, True)
        self.rootFolder = psetup.rootFolder
        setUpSiteManagerLookup()

        import zope.i18n.interfaces
        import zope.i18n.negotiator
        provideUtility(zope.i18n.negotiator.negotiator,
                       zope.i18n.interfaces.INegotiator)

        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        de_catalog.setMessage('long_greeting', 'Guten Tag!', 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain('default')
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, 'default')

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = 'default'
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo Welt!', 10)
        td['de-default-1'] = de_catalog

        mgr = createSiteManager(traverse(self.rootFolder, 'folder1'))
        mgr['default']['default'] = td
        mgr.registerUtility(mgr['default']['default'], ITranslationDomain,
                            'default')

        self.trans1 = td
        self.trans = domain
Beispiel #2
0
    def setUp(self):
        super(TranslateTest, self).setUp()

        # Setup the registries
        ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets,
                             HTTPCharsets)

        ztapi.provideUtility(IFactory, Factory(MessageCatalog),
                             'zope.app.MessageCatalog')

        domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')

        en_catalog.setMessage('short_greeting', 'Hello!')
        de_catalog.setMessage('short_greeting', 'Hallo!')

        en_catalog.setMessage('greeting', 'Hello $name, how are you?')
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?')

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog

        self._view = Translate(domain, self._getRequest())
    def setUp(self):
        setup.placefulSetUp()
        self.rootFolder = setup.buildSampleFolderTree()
        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo!", 10)
        de_catalog.setMessage("long_greeting", "Guten Tag!", 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain("default")
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, "default")

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = "default"
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo Welt!", 10)
        td["de-default-1"] = de_catalog

        mgr = setup.createSiteManager(traverse(self.rootFolder, "folder1"))
        setup.addUtility(mgr, "default", interfaces.ILocalTranslationDomain, td)

        self.trans1 = td
        self.trans = domain
    def setUp(self):
        setup.placefulSetUp()
        self.rootFolder = setup.buildSampleFolderTree()
        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        de_catalog.setMessage('long_greeting', 'Guten Tag!', 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain('default')
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, 'default')

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = 'default'
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo Welt!', 10)
        td['de-default-1'] = de_catalog

        mgr = setup.createSiteManager(traverse(self.rootFolder, 'folder1'))
        setup.addUtility(
            mgr, 'default', interfaces.ILocalTranslationDomain, td)

        self.trans1 = td
        self.trans = domain
    def setUp(self):
        psetup = PlacefulSetup()
        self.sm = psetup.setUp(True, True)
        self.rootFolder = psetup.rootFolder
        setUpSiteManagerLookup()

        import zope.i18n.interfaces
        import zope.i18n.negotiator
        provideUtility(zope.i18n.negotiator.negotiator,
                       zope.i18n.interfaces.INegotiator)


        gsm = getGlobalSiteManager()
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        de_catalog.setMessage('long_greeting', 'Guten Tag!', 10)

        # register global translation domain and add the catalog.
        domain = GlobalTranslationDomain('default')
        domain.addCatalog(de_catalog)
        gsm.registerUtility(domain, ITranslationDomain, 'default')

        # create a local site manager and add a local translation domain
        td = TranslationDomain()
        td.domain = 'default'
        de_catalog = MessageCatalog('de', 'default')
        de_catalog.setMessage('short_greeting', 'Hallo Welt!', 10)
        td['de-default-1'] = de_catalog

        mgr = createSiteManager(traverse(self.rootFolder, 'folder1'))
        mgr['default']['default'] = td
        mgr.registerUtility(mgr['default']['default'], ITranslationDomain, 'default')

        self.trans1 = td
        self.trans = domain
    def setUp(self):
        self._domain = domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')

        en_catalog.setMessage('short_greeting', 'Hello!')
        de_catalog.setMessage('short_greeting', 'Hallo!')

        en_catalog.setMessage('greeting', 'Hello $name, how are you?')
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?')

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog
def getMessageCatalogs(locales):
    catalogs = {}

    # Parse message catalogs from the theme
    for language in locales.listDirectory():
        if not locales.isDirectory(language):
            continue
        directory = locales[language]
        if not directory.isDirectory('LC_MESSAGES'):
            continue
        directory = directory['LC_MESSAGES']
        for po in directory.listDirectory():
            if not po.endswith('.po') or not directory.isFile(po):
                continue
            domain = po.rsplit('.', 1)[0]
            catalogs.setdefault(domain, {})
            catalogs[domain][language] = MessageCatalog(language, domain)
            for msg in pofile(str(directory.readFile(po))):
                if not msg.msgstr:
                    continue  # Disallows overrides with empty strings
                catalogs[domain][language].setMessage(
                    unicode(msg.msgid, 'utf-8', 'ignore'),
                    unicode(msg.msgstr, 'utf-8', 'ignore'))

    return catalogs
    def setUp(self):
        super(TestMethods, self).setUp()

        domain = self._domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')
        # Populate the catalogs with translations of a message id
        en_catalog.setMessage('short_greeting', 'Hello!', 10)
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        # And another message id with interpolation placeholders
        en_catalog.setMessage('greeting', 'Hello $name, how are you?', 0)
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?', 0)

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog
    def _getTranslationDomain(self):
        domain = TranslationDomain()
        domain.domain = "default"

        en_catalog = MessageCatalog("en", "default")
        de_catalog = MessageCatalog("de", "default")
        # Populate the catalogs with translations of a message id
        en_catalog.setMessage("short_greeting", "Hello!", 10)
        de_catalog.setMessage("short_greeting", "Hallo!", 10)
        # And another message id with interpolation placeholders
        en_catalog.setMessage("greeting", "Hello $name, how are you?", 0)
        de_catalog.setMessage("greeting", "Hallo $name, wie geht es Dir?", 0)

        domain["en-1"] = en_catalog
        domain["de-1"] = de_catalog

        return domain
    def setUp(self):
        setup.placefulSetUp()
        self.rootFolder = setup.buildSampleFolderTree()
        sm = zapi.getGlobalSiteManager()
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo!", 10)

        # Create global translation domain and add the catalog.
        domain = GlobalTranslationDomain("default")
        domain.addCatalog(de_catalog)
        sm.provideUtility(ITranslationDomain, domain, "default")

        # Create Domain in root folder
        mgr = setup.createSiteManager(self.rootFolder)
        self.trans = setup.addDomain(mgr, Translation, TranslationDomain())

        # Create Domain in folder1
        mgr = setup.createSiteManager(zapi.traverse(self.rootFolder, "folder1"))
        td = TranslationDomain()
        td.domain = "default"
        de_catalog = MessageCatalog("de", "default")
        de_catalog.setMessage("short_greeting", "Hallo Welt!", 10)
        td["de-default-1"] = de_catalog
        self.trans1 = setup.addDomain(mgr, Translation, ts)
Beispiel #11
0
 def _getMessageCatalog(self):
     catalog = MessageCatalog('en', 'default')
     catalog.setMessage('short_greeting', 'Hello!', 0)
     catalog.setMessage('greeting', 'Hello $name, how are you?', 0)
     return catalog
    def setUp(self):
        super(TestMethods, self).setUp()

        domain = self._domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')
        # Populate the catalogs with translations of a message id
        en_catalog.setMessage('short_greeting', 'Hello!', 10)
        de_catalog.setMessage('short_greeting', 'Hallo!', 10)
        # And another message id with interpolation placeholders
        en_catalog.setMessage('greeting', 'Hello $name, how are you?', 0)
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?', 0)

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog
Beispiel #13
0
 def _getMessageCatalog(self):
     catalog = MessageCatalog('en', 'default')
     catalog.setMessage('short_greeting', 'Hello!', 0)
     catalog.setMessage('greeting', 'Hello $name, how are you?', 0)
     return catalog
Beispiel #14
0
    def setUp(self):
        super(TranslateTest, self).setUp()

        # Setup the registries
        provideAdapter(HTTPCharsets, (IHTTPRequest, ), IUserPreferredCharsets)

        provideUtility(Factory(MessageCatalog), IFactory,
                       'zope.app.MessageCatalog')

        self._domain = domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')

        en_catalog.setMessage('short_greeting', 'Hello!')
        de_catalog.setMessage('short_greeting', 'Hallo!')

        en_catalog.setMessage('greeting', 'Hello $name, how are you?')
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?')

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog

        self._view = Translate(domain, self._getRequest())
Beispiel #15
0
    def setUp(self):
        self._domain = domain = TranslationDomain()
        domain.domain = 'default'

        en_catalog = MessageCatalog('en', 'default')
        de_catalog = MessageCatalog('de', 'default')

        en_catalog.setMessage('short_greeting', 'Hello!')
        de_catalog.setMessage('short_greeting', 'Hallo!')

        en_catalog.setMessage('greeting', 'Hello $name, how are you?')
        de_catalog.setMessage('greeting', 'Hallo $name, wie geht es Dir?')

        domain['en-1'] = en_catalog
        domain['de-1'] = de_catalog