def setUp(self):
     # MultipleDomainsDummyEngine is a Engine
     # where default domain transforms to uppercase
     self.engine = MultipleDomainsDummyEngine()
     self.engine.setLocal(
         'foo', self.factory('FoOvAlUe${empty}', 'default', {'empty': ''}))
     self.engine.setLocal('bar', 'BaRvAlUe')
     self.engine.setLocal('baz', self.factory('BaZvAlUe', 'default', {}))
     # Message ids with different domains
     self.engine.setLocal('toupper', self.factory('ToUpper', 'default', {}))
     self.engine.setLocal(
         'tolower', self.factory('ToLower', 'default', {}, domain='lower'))
Esempio n. 2
0
 def setUp(self):
     # MultipleDomainsDummyEngine is a Engine
     # where default domain transforms to uppercase
     self.engine = MultipleDomainsDummyEngine()
     self.engine.setLocal('foo',
         self.factory('FoOvAlUe${empty}', 'default', {'empty': ''}))
     self.engine.setLocal('bar', 'BaRvAlUe')
     self.engine.setLocal('baz',
         self.factory('BaZvAlUe', 'default', {}))
     # Message ids with different domains
     self.engine.setLocal('toupper',
         self.factory('ToUpper', 'default', {}))
     self.engine.setLocal('tolower',
         self.factory('ToLower', 'default', {}, domain='lower'))
class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessage):
    def setUp(self):
        # MultipleDomainsDummyEngine is a Engine
        # where default domain transforms to uppercase
        self.engine = MultipleDomainsDummyEngine()
        self.engine.setLocal(
            'foo', self.factory('FoOvAlUe${empty}', 'default', {'empty': ''}))
        self.engine.setLocal('bar', 'BaRvAlUe')
        self.engine.setLocal('baz', self.factory('BaZvAlUe', 'default', {}))
        # Message ids with different domains
        self.engine.setLocal('toupper', self.factory('ToUpper', 'default', {}))
        self.engine.setLocal(
            'tolower', self.factory('ToLower', 'default', {}, domain='lower'))

    def test_multiple_domains(self):
        program, _macros = self._compile('<div i18n:translate=""'
                                         '     tal:content="toupper" />')
        self._check(program, '<div>TOUPPER</div>')
        program, _macros = self._compile('<div i18n:translate=""'
                                         '     tal:content="tolower" />')
        self._check(program, '<div>tolower</div>')
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     tal:content="string:ToUpper" />')
        self._check(program, '<div>TOUPPER</div>')
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="lower"'
            '     tal:content="string:ToLower" />')
        self._check(program, '<div>tolower</div>')
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     tal:define="msgid string:ToUpper"'
            '     tal:content="msgid" />')
        self._check(program, '<div>TOUPPER</div>')
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="lower"'
            '     tal:define="msgid string:ToLower"'
            '     tal:content="msgid" />')
        self._check(program, '<div>tolower</div>')

    def test_unused_explicit_domain(self):
        #a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine
        #is a domain that transforms to lowercase
        self.engine.setLocal(
            'othertolower',
            self.factory(
                'OtherToLower',
                'a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine',
                {},
                domain='lower'))
        program, _macros = self._compile('<div i18n:translate=""'
                                         '     tal:content="othertolower" />')
        self._check(program, '<div>othertolower</div>')
        #takes domain into account for strings
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine"'
            '     tal:content="string:ToLower" />')
        self._check(program, '<div>tolower</div>')
        #but not for messageids
        program, _macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine"'
            '     tal:content="baz" />')
        self._check(program, '<div>BAZVALUE</div>')
Esempio n. 4
0
class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessageID):
    
    def factory(self, msgid, default=None, mapping={}, domain=None):
        m = MessageID(msgid, default=default, domain=domain)
        m.mapping = mapping
        return m

    
    def setUp(self):
        # MultipleDomainsDummyEngine is a Engine
        # where default domain transforms to uppercase
        self.engine = MultipleDomainsDummyEngine()
        self.engine.setLocal('foo',
            self.factory('FoOvAlUe${empty}', 'default', {'empty': ''}))
        self.engine.setLocal('bar', 'BaRvAlUe')
        self.engine.setLocal('baz',
            self.factory('BaZvAlUe', 'default', {}))
        # Message ids with different domains
        self.engine.setLocal('toupper',
            self.factory('ToUpper', 'default', {}))
        self.engine.setLocal('tolower',
            self.factory('ToLower', 'default', {}, domain='lower'))

    def test_multiple_domains(self):
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     tal:content="toupper" />')
        self._check(program, '<div>TOUPPER</div>\n')
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     tal:content="tolower" />')
        self._check(program, '<div>tolower</div>\n')
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     tal:content="string:ToUpper" />')
        self._check(program, '<div>TOUPPER</div>\n')
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="lower"'
            '     tal:content="string:ToLower" />')
        self._check(program, '<div>tolower</div>\n')
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     tal:define="msgid string:ToUpper"'
            '     tal:content="msgid" />')
        self._check(program, '<div>TOUPPER</div>\n')
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="lower"'
            '     tal:define="msgid string:ToLower"'
            '     tal:content="msgid" />')
        self._check(program, '<div>tolower</div>\n')

    def test_unused_explicit_domain(self):
        #a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine 
        #is a domain that transforms to lowercase
        self.engine.setLocal('othertolower',
            self.factory('OtherToLower', 'a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine', {}, domain='lower'))
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     tal:content="othertolower" />')
        self._check(program, '<div>othertolower</div>\n')
        #takes domain into account for strings
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine"'
            '     tal:content="string:ToLower" />')
        self._check(program, '<div>tolower</div>\n')
        #but not for messageids
        program, macros = self._compile(
            '<div i18n:translate=""'
            '     i18n:domain="a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine"'
            '     tal:content="baz" />')
        self._check(program, '<div>BAZVALUE</div>\n')