Example #1
0
 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',
         ]
     )
Example #2
0
 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',
         ]
     )
Example #3
0
 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'
     )
Example #4
0
 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'
     )
Example #5
0
 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')
Example #6
0
 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'
     )
Example #7
0
 def setUp(self):
     self.unit = Unit(
         translation=Translation(
             subproject=SubProject()
         )
     )
     self.profile = Profile()
Example #8
0
 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)
Example #9
0
 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",
         ],
     )
Example #10
0
 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)
Example #11
0
 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")