def test_cleanTranslationFiles(self): """ Extra strings will be removed and re-arranged to match the order of the strings in the default language """ # get the keys from the default language keys = localizr.getKeysFromTree(self.tree) # clean the fiels localizr.createOutputDir('./to_translate') localizr.cleanTranslationFiles(self.LANGS, keys, self.res_path) # verify that German strings are correctly sorted os.chdir(self.cwd) self.assertTrue(filecmp.cmp('./test/res/values-de/strings.xml', './test/test_cleaned/res/values-de/strings.xml')) # verify that empty spanish strings stays empty os.chdir(self.cwd) self.assertTrue(filecmp.cmp('./test/res/values-es/strings.xml', './test/test_cleaned/res/values-es/strings.xml')) # verify that extra french string is removed os.chdir(self.cwd) self.assertTrue(filecmp.cmp('./test/res/values-fr/strings.xml', './test/test_cleaned/res/values-fr/strings.xml')) # verify that extra chinese string is removed and everything else is # the same os.chdir(self.cwd) self.assertTrue(filecmp.cmp('./test/res/values-zh-rTW/strings.xml', './test/test_cleaned/res/values-zh-rTW/strings.xml'))
def test_writeOutMissingStrings(self): # get tags from default tree so we know what to write out tags = localizr.getTagsFromTree(self.tree) # get the missing keys for each lang keys = localizr.getKeysFromTree(self.tree) missing = localizr.findMissingKeys(keys, self.LANGS, self.res_path) # write out the files localizr.createOutputDir('./test/to_translate') localizr.writeMissingKeysToFiles(self.LANGS, tags, missing, './test/to_translate') # verify that no German strings exist os.chdir(self.cwd) self.assertFalse( os.path.exists('./test/to_translate/strings_to_trans-de.xml')) # verify that spanish strings seem correct os.chdir(self.cwd) self.assertTrue( os.path.exists('./test/to_translate/strings_to_trans-es.xml')) self.assertTrue( filecmp.cmp('./test/test_to_translate/strings_to_trans-es.xml', './test/to_translate/strings_to_trans-es.xml')) # verify that french strings seem correct os.chdir(self.cwd) self.assertTrue( os.path.exists('./test/to_translate/strings_to_trans-fr.xml')) self.assertTrue( filecmp.cmp('./test/test_to_translate/strings_to_trans-fr.xml', './test/to_translate/strings_to_trans-fr.xml')) # verify that traditional chinese strings seem correct os.chdir(self.cwd) self.assertTrue( os.path.exists('./test/to_translate/strings_to_trans-zh-rTW.xml')) self.assertTrue( filecmp.cmp('./test/test_to_translate/strings_to_trans-zh-rTW.xml', './test/to_translate/strings_to_trans-zh-rTW.xml'))
def test_writeOutMissingStrings(self): # get tags from default tree so we know what to write out tags = localizr.getTagsFromTree(self.tree) # get the missing keys for each lang keys = localizr.getKeysFromTree(self.tree) missing = localizr.findMissingKeys(keys, self.LANGS, self.res_path) # write out the files localizr.createOutputDir('./test/to_translate') localizr.writeMissingKeysToFiles(self.LANGS, tags, missing, './test/to_translate') # verify that no German strings exist os.chdir(self.cwd) self.assertFalse(os.path.exists( './test/to_translate/strings_to_trans-de.xml')) # verify that spanish strings seem correct os.chdir(self.cwd) self.assertTrue(os.path.exists( './test/to_translate/strings_to_trans-es.xml')) self.assertTrue(filecmp.cmp( './test/test_to_translate/strings_to_trans-es.xml', './test/to_translate/strings_to_trans-es.xml')) # verify that french strings seem correct os.chdir(self.cwd) self.assertTrue(os.path.exists( './test/to_translate/strings_to_trans-fr.xml')) self.assertTrue(filecmp.cmp( './test/test_to_translate/strings_to_trans-fr.xml', './test/to_translate/strings_to_trans-fr.xml')) # verify that traditional chinese strings seem correct os.chdir(self.cwd) self.assertTrue(os.path.exists( './test/to_translate/strings_to_trans-zh-rTW.xml')) self.assertTrue(filecmp.cmp( './test/test_to_translate/strings_to_trans-zh-rTW.xml', './test/to_translate/strings_to_trans-zh-rTW.xml'))
def test_cleanTranslationFiles(self): """ Extra strings will be removed and re-arranged to match the order of the strings in the default language """ # get the keys from the default language keys = localizr.getKeysFromTree(self.tree) # clean the fiels localizr.createOutputDir('./to_translate') localizr.cleanTranslationFiles(self.LANGS, keys, self.res_path) # verify that German strings are correctly sorted os.chdir(self.cwd) self.assertTrue( filecmp.cmp('./test/res/values-de/strings.xml', './test/test_cleaned/res/values-de/strings.xml')) # verify that empty spanish strings stays empty os.chdir(self.cwd) self.assertTrue( filecmp.cmp('./test/res/values-es/strings.xml', './test/test_cleaned/res/values-es/strings.xml')) # verify that extra french string is removed os.chdir(self.cwd) self.assertTrue( filecmp.cmp('./test/res/values-fr/strings.xml', './test/test_cleaned/res/values-fr/strings.xml')) # verify that extra chinese string is removed and everything else is # the same os.chdir(self.cwd) self.assertTrue( filecmp.cmp('./test/res/values-zh-rTW/strings.xml', './test/test_cleaned/res/values-zh-rTW/strings.xml'))