Пример #1
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())
Пример #2
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())
Пример #3
0
    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
Пример #4
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
Пример #5
0
    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
Пример #7
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
    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
Пример #9
0
    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
Пример #10
0
    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
Пример #11
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
Пример #12
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)
Пример #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
Пример #14
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