def test_lang_code(self): subproject = SubProject() subproject.filemask = 'Solution/Project/Resources.*.resx' self.assertEqual( subproject.get_lang_code('Solution/Project/Resources.es-mx.resx'), 'es-mx' ) self.assertEqual( subproject.get_lang_code('Solution/Project/Resources.resx'), '' ) self.assertRaisesMessage( ValidationError, 'Got empty language code for ' 'Solution/Project/Resources.resx, please check filemask!', subproject.clean_lang_codes, [ 'Solution/Project/Resources.resx', 'Solution/Project/Resources.de.resx', 'Solution/Project/Resources.es.resx', 'Solution/Project/Resources.es-mx.resx', 'Solution/Project/Resources.fr.resx', 'Solution/Project/Resources.fr-fr.resx', ] )
def test_lang_code_template(self): subproject = SubProject(project=Project()) subproject.filemask = 'Solution/Project/Resources.*.resx' subproject.template = 'Solution/Project/Resources.resx' self.assertEqual( subproject.get_lang_code('Solution/Project/Resources.resx'), 'en' )
def test_lang_code_double(self): subproject = SubProject() subproject.filemask = 'path/*/resources/MessagesBundle_*.properties' self.assertEqual( subproject.get_lang_code( 'path/pt/resources/MessagesBundle_pt_BR.properties'), 'pt_BR') self.assertEqual( subproject.get_lang_code( 'path/el/resources/MessagesBundle_el.properties'), 'el')
def test_lang_code_double(self): subproject = SubProject() subproject.filemask = 'path/*/resources/MessagesBundle_*.properties' self.assertEqual( subproject.get_lang_code( 'path/pt/resources/MessagesBundle_pt_BR.properties' ), 'pt_BR' ) self.assertEqual( subproject.get_lang_code( 'path/el/resources/MessagesBundle_el.properties' ), 'el' )
def setUp(self): self.unit = Unit( translation=Translation( subproject=SubProject() ) ) self.profile = Profile()
def check_unit(self, nplurals=3, **kwargs): if nplurals == 3: equation = 'n==0 ? 0 : n==1 ? 1 : 2' else: equation = '0' lang = Language( code='zz', nplurals=nplurals, pluralequation=equation ) project = Project( slug='test', source_language=Language.objects.get(code='en'), ) subproject = SubProject(slug='comp', project=project) unit = Unit( translation=Translation( language=lang, subproject=subproject ), **kwargs ) exporter = self.get_exporter(lang) exporter.add_unit(unit) return self.check_export(exporter)
def test_lang_code(self): subproject = SubProject() subproject.filemask = "Solution/Project/Resources.*.resx" self.assertEqual(subproject.get_lang_code("Solution/Project/Resources.es-mx.resx"), "es-mx") self.assertEqual(subproject.get_lang_code("Solution/Project/Resources.resx"), "") self.assertRaisesMessage( ValidationError, "Got empty language code for " "Solution/Project/Resources.resx, please check filemask!", subproject.clean_lang_codes, [ "Solution/Project/Resources.resx", "Solution/Project/Resources.de.resx", "Solution/Project/Resources.es.resx", "Solution/Project/Resources.es-mx.resx", "Solution/Project/Resources.fr.resx", "Solution/Project/Resources.fr-fr.resx", ], )
def check_unit(self, nplurals=3, **kwargs): lang = Language(code='zz', nplurals=nplurals) project = Project( slug='test', source_language=Language.objects.get(code='en'), ) subproject = SubProject(slug='comp', project=project) unit = Unit(translation=Translation(language=lang, subproject=subproject), **kwargs) exporter = self.get_exporter() exporter.add_unit(unit) return self.check_export(exporter)
def test_lang_code_template(self): subproject = SubProject() subproject.filemask = "Solution/Project/Resources.*.resx" subproject.template = "Solution/Project/Resources.resx" self.assertEqual(subproject.get_lang_code("Solution/Project/Resources.resx"), "en")