mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-10-01 03:43:51 +08:00
pre-commit: speed up translation step (#30966)
* formatting fix * fix missing class attr warning * add translation_files option, remove pluralonly, type hint * updates * update old-commit-hash: bef6d7f0bb1f985fa959627d674210c46870d914
This commit is contained in:
@@ -22,6 +22,9 @@ FORMAT_ARG = re.compile("%[0-9]+")
|
||||
|
||||
@parameterized_class(("name", "file"), translation_files.items())
|
||||
class TestTranslations(unittest.TestCase):
|
||||
name: str
|
||||
file: str
|
||||
|
||||
@staticmethod
|
||||
def _read_translation_file(path, file):
|
||||
tr_file = os.path.join(path, f"{file}.ts")
|
||||
@@ -30,12 +33,12 @@ class TestTranslations(unittest.TestCase):
|
||||
|
||||
def test_missing_translation_files(self):
|
||||
self.assertTrue(os.path.exists(os.path.join(TRANSLATIONS_DIR, f"{self.file}.ts")),
|
||||
f"{self.name} has no XML translation file, run selfdrive/ui/update_translations.py")
|
||||
f"{self.name} has no XML translation file, run selfdrive/ui/update_translations.py")
|
||||
|
||||
def test_translations_updated(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
shutil.copytree(TRANSLATIONS_DIR, tmpdir, dirs_exist_ok=True)
|
||||
update_translations(plural_only=["main_en"], translations_dir=tmpdir)
|
||||
update_translations(translation_files=[self.file], translations_dir=tmpdir)
|
||||
|
||||
cur_translations = self._read_translation_file(TRANSLATIONS_DIR, self.file)
|
||||
new_translations = self._read_translation_file(tmpdir, self.file)
|
||||
|
||||
Reference in New Issue
Block a user