diff --git a/selfdrive/ui/tests/test_translations.py b/selfdrive/ui/tests/test_translations.py index 5e52eabe3a..3c400f18d2 100755 --- a/selfdrive/ui/tests/test_translations.py +++ b/selfdrive/ui/tests/test_translations.py @@ -67,11 +67,14 @@ class TestTranslations(unittest.TestCase): self.assertTrue("" not in cur_translations, f"{file} ({name}) translation file has obsolete translations. Run selfdrive/ui/update_translations.py --vanish to remove them") - def test_plural_translations(self): + def test_finished_translations(self): """ - Tests: - - that any numerus (plural) translations marked "finished" have all plural forms non-empty + Tests ran on each translation marked "finished" + Plural: + - that any numerus (plural) translations have all plural forms non-empty - that the correct format specifier is used (%n) + Non-plural: + - that translation is not empty """ for name, file in self.translation_files.items(): with self.subTest(name=name, file=file): @@ -79,17 +82,23 @@ class TestTranslations(unittest.TestCase): for context in tr_xml.getroot(): for message in context.iterfind("message"): + translation = message.find("translation") + source_text = message.find("source").text + + # Do not test unfinished translations + if translation.get("type") == "unfinished": + continue + if message.get("numerus") == "yes": - translation = message.find("translation") numerusform = [t.text for t in translation.findall("numerusform")] - # Do not assert finished translations - if translation.get("type") == "unfinished": - continue + for nf in numerusform: + self.assertIsNotNone(nf, f"Ensure all plural translation forms are completed: {source_text}") + self.assertIn("%n", nf, "Ensure numerus argument (%n) exists in translation.") + self.assertIsNone(re.search("%[0-9]+", nf), "Plural translations must use %n, not %1, %2, etc.: {}".format(numerusform)) - self.assertNotIn(None, numerusform, "Ensure all plural translation forms are completed.") - self.assertTrue(all(re.search("%[0-9]+", t) is None for t in numerusform), - "Plural translations must use %n, not %1, %2, etc.: {}".format(numerusform)) + else: + self.assertIsNotNone(translation.text, f"Ensure translation is completed: {source_text}") def test_no_locations(self): for name, file in self.translation_files.items(): diff --git a/selfdrive/ui/translations/main_zh-CHT.ts b/selfdrive/ui/translations/main_zh-CHT.ts index 83ab5d8aa3..084cc13c3c 100644 --- a/selfdrive/ui/translations/main_zh-CHT.ts +++ b/selfdrive/ui/translations/main_zh-CHT.ts @@ -836,27 +836,27 @@ This may take up to a minute. Wi-Fi - + ETH - + 2G - + 3G - + LTE - + 5G - +