def test_findMissingKeys(self): """ look for missing keys in the translated values.xml files """ keys = localizr.getKeysFromTree(self.tree) missing = localizr.findMissingKeys(keys, self.LANGS, self.res_path) # verify that German is not missing any tags self.assertEqual(missing['de'], []) # verify that Spanish is missing all tags self.assertEqual(missing['es'], [('string', 'test_1'), ('string', 'test_2'), ('string', 'test_3'), ('string', 'test_4'), ('string', 'test_5'), ('plurals', 'plurals_test')]) # verify that French is missing all tags (despite its extra tag) self.assertEqual(missing['fr'], [('string', 'test_1'), ('string', 'test_2'), ('string', 'test_3'), ('string', 'test_4'), ('string', 'test_5'), ('plurals', 'plurals_test')]) # verify that traditional Chinese is only missing one tag self.assertEqual(missing['zh-rTW'], [('string', 'test_5'), ('plurals', 'plurals_test')])
def test_findMissingKeys(self): """ look for missing keys in the translated values.xml files """ keys = localizr.getKeysFromTree(self.tree) missing = localizr.findMissingKeys(keys, self.LANGS, self.res_path) # verify that German is not missing any tags self.assertEqual(missing['de'], []) # verify that Spanish is missing all tags self.assertEqual( missing['es'], [('string', 'test_1'), ('string', 'test_2'), ('string', 'test_3'), ('string', 'test_4'), ('string', 'test_5'), ('plurals', 'plurals_test')]) # verify that French is missing all tags (despite its extra tag) self.assertEqual( missing['fr'], [('string', 'test_1'), ('string', 'test_2'), ('string', 'test_3'), ('string', 'test_4'), ('string', 'test_5'), ('plurals', 'plurals_test')]) # verify that traditional Chinese is only missing one tag self.assertEqual( missing['zh-rTW'], [('string', 'test_5'), ('plurals', 'plurals_test')])
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'))