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
Esempio n. 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())
Esempio n. 3
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
    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 _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
Esempio n. 7
0
    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 _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
Esempio n. 9
0
    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)