mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 11:02:19 +08:00
Multilang: test for vanished translations (#25342)
* Test for vanished translations * this isn't needed anymore * comment * remove more unnecessary code since the great pluralization old-commit-hash: eaf21e53e2a3e3e988b661412c919a331b5cf2a9
This commit is contained in:
@@ -32,9 +32,6 @@ class TestTranslations(unittest.TestCase):
|
||||
def test_missing_translation_files(self):
|
||||
for name, file in self.translation_files.items():
|
||||
with self.subTest(name=name, file=file):
|
||||
if not len(file):
|
||||
self.skipTest(f"{name} translation has no defined file")
|
||||
|
||||
self.assertTrue(os.path.exists(os.path.join(TRANSLATIONS_DIR, f"{file}.ts")),
|
||||
f"{name} has no XML translation file, run selfdrive/ui/update_translations.py")
|
||||
|
||||
@@ -43,9 +40,6 @@ class TestTranslations(unittest.TestCase):
|
||||
|
||||
for name, file in self.translation_files.items():
|
||||
with self.subTest(name=name, file=file):
|
||||
if not len(file):
|
||||
self.skipTest(f"{name} translation has no defined file")
|
||||
|
||||
# caught by test_missing_translation_files
|
||||
if not os.path.exists(os.path.join(TRANSLATIONS_DIR, f"{file}.ts")):
|
||||
self.skipTest(f"{name} missing translation file")
|
||||
@@ -59,13 +53,17 @@ class TestTranslations(unittest.TestCase):
|
||||
def test_unfinished_translations(self):
|
||||
for name, file in self.translation_files.items():
|
||||
with self.subTest(name=name, file=file):
|
||||
if not len(file):
|
||||
raise self.skipTest(f"{name} translation has no defined file")
|
||||
|
||||
cur_translations = self._read_translation_file(TRANSLATIONS_DIR, file)
|
||||
self.assertTrue(b"<translation type=\"unfinished\">" not in cur_translations,
|
||||
f"{file} ({name}) translation file has unfinished translations. Finish translations or mark them as completed in Qt Linguist")
|
||||
|
||||
def test_vanished_translations(self):
|
||||
for name, file in self.translation_files.items():
|
||||
with self.subTest(name=name, file=file):
|
||||
cur_translations = self._read_translation_file(TRANSLATIONS_DIR, file)
|
||||
self.assertTrue(b"<translation type=\"vanished\">" not in cur_translations,
|
||||
f"{file} ({name}) translation file has obsolete translations. Run selfdrive/ui/update_translations.py --vanish to remove them")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -17,9 +17,6 @@ if __name__ == "__main__":
|
||||
|
||||
print("Copy into selfdrive/ui/translations/README.md:\n")
|
||||
for name, file in translation_files.items():
|
||||
if not len(file):
|
||||
continue
|
||||
|
||||
with open(os.path.join(TRANSLATIONS_DIR, f"{file}.ts"), "r") as tr_f:
|
||||
tr_file = tr_f.read()
|
||||
|
||||
|
||||
@@ -18,10 +18,6 @@ def update_translations(vanish=False, plural_only=None, translations_dir=TRANSLA
|
||||
translation_files = json.load(f)
|
||||
|
||||
for name, file in translation_files.items():
|
||||
if not len(file):
|
||||
print(f"{name} has no translation file, skipping...")
|
||||
continue
|
||||
|
||||
tr_file = os.path.join(translations_dir, f"{file}.ts")
|
||||
args = f"lupdate -recursive {UI_DIR} -ts {tr_file}"
|
||||
if vanish:
|
||||
|
||||
Reference in New Issue
Block a user