Ejemplo n.º 1
0
    def test_ngettext_1(self):
        t = MultiStringTranslation('de')
        t._catalog['KEY'] = ['VALUE1', 'VALUE2', 'VALUE3']
        t._catalog['KEY_PLURAL'] = ['VALUEA', 'VALUEB', 'VALUEC']

        self.assertIn(t.ngettext('KEY', 'KEY_PLURAL', 1),
                      ['VALUE1', 'VALUE2', 'VALUE3'])
Ejemplo n.º 2
0
 def test_reload_no_data(self, req_mock):
     req_mock.get(
         'http://service-text-service:1555/v1/text/de/unnamed-skill',
         text='[]')
     t = MultiStringTranslation('de')
     with self.assertRaises(l10n.TranslationError):
         t.reload()
Ejemplo n.º 3
0
 def test_getalltexts(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['VALUE1', 'VALUE2', 'VALUE3']
     self.assertEqual(t.getalltexts('KEY'), ['VALUE1', 'VALUE2', 'VALUE3'])
     from skill_sdk.l10n import _a
     l10n.set_current_locale(t)
     self.assertEqual(_a('KEY'), ['VALUE1', 'VALUE2', 'VALUE3'])
Ejemplo n.º 4
0
 def test_reload(self, req_mock):
     req_mock.get(
         'http://service-text-service:1555/v1/text/de/unnamed-skill',
         text='[{"locale": "de","scope": "unnamed-skill",'
         '"sentences": ["SCHLÜSSEL1", "SCHLÜSSEL2"],'
         '"tag": "KEY"}]')
     t = MultiStringTranslation('de')
     t.reload()
     self.assertEqual(t._catalog['KEY'], ['SCHLÜSSEL1', 'SCHLÜSSEL2'])
Ejemplo n.º 5
0
 def test_getalltexts_empty_catalog(self):
     t = MultiStringTranslation('de')
     self.assertEqual(t.getalltexts('ABC'), ['ABC'])
Ejemplo n.º 6
0
 def test_gettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['VALUE1', 'VALUE2', 'VALUE3']
     self.assertIn(t.gettext('KEY'), ['VALUE1', 'VALUE2', 'VALUE3'])
Ejemplo n.º 7
0
 def test_lngettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['üöä']
     t._catalog['KEY_PLURAL'] = ['äöü']
     self.assertEqual(t.lngettext('KEY', 'KEY_PLURAL', 2),
                      b'\xc3\xa4\xc3\xb6\xc3\xbc')
Ejemplo n.º 8
0
 def test_gettext_empty_catalog(self):
     t = MultiStringTranslation('de')
     self.assertEqual(t.gettext('ABC'), 'ABC')
Ejemplo n.º 9
0
 def test_lgettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['äöü']
     self.assertEqual(t.lgettext('KEY'), b'\xc3\xa4\xc3\xb6\xc3\xbc')
Ejemplo n.º 10
0
 def test_markgettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['äöü']
     self.assertEqual(t.markgettext('KEY'), 'KEY')
Ejemplo n.º 11
0
 def test_init_i18n_scope_name(self, config_mock):
     config_mock['i18n'] = {'scope': 'testingskill'}
     t = MultiStringTranslation('zh')
     self.assertEqual(t.locale, 'zh')
     self.assertEqual(t._catalog, {})
Ejemplo n.º 12
0
 def test_init_only_skill_name(self, config_mock):
     config_mock['skill'] = {'name': 'testingskill'}
     t = MultiStringTranslation('zh')
     self.assertEqual(t.locale, 'zh')
     self.assertEqual(t._catalog, {})
Ejemplo n.º 13
0
 def test_init_no_conf(self):
     t = MultiStringTranslation('zh')
     self.assertEqual(t.locale, 'zh')
     self.assertEqual(t._catalog, {})