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'])
 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()
 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'])
 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'])
 def test_getalltexts_empty_catalog(self):
     t = MultiStringTranslation('de')
     self.assertEqual(t.getalltexts('ABC'), ['ABC'])
 def test_gettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['VALUE1', 'VALUE2', 'VALUE3']
     self.assertIn(t.gettext('KEY'), ['VALUE1', 'VALUE2', 'VALUE3'])
 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')
 def test_gettext_empty_catalog(self):
     t = MultiStringTranslation('de')
     self.assertEqual(t.gettext('ABC'), 'ABC')
 def test_lgettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['äöü']
     self.assertEqual(t.lgettext('KEY'), b'\xc3\xa4\xc3\xb6\xc3\xbc')
 def test_markgettext(self):
     t = MultiStringTranslation('de')
     t._catalog['KEY'] = ['äöü']
     self.assertEqual(t.markgettext('KEY'), 'KEY')
 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, {})
 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, {})
 def test_init_no_conf(self):
     t = MultiStringTranslation('zh')
     self.assertEqual(t.locale, 'zh')
     self.assertEqual(t._catalog, {})