From 30562c9d26fdc8c8ef0a0fc9bd27587ff3af4a7c Mon Sep 17 00:00:00 2001 From: Francesco Lodolo Date: Sun, 30 Jun 2024 08:51:38 +0200 Subject: [PATCH 1/3] Android: flag extra parameters as error when reference has none --- compare_locales/checks/android.py | 4 ++-- compare_locales/tests/android/test_checks.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compare_locales/checks/android.py b/compare_locales/checks/android.py index a9b5de2..4a44082 100644 --- a/compare_locales/checks/android.py +++ b/compare_locales/checks/android.py @@ -61,8 +61,8 @@ def check_string(self, refs, l10nEnt): params, count, errors = get_params(refs) for error, pos in errors: yield ("warning", pos, error, "android") - if params: - yield from check_params(params, count, l10nEnt.val) + # Always check parameters, as the translation might have additional ones + yield from check_params(params, count, l10nEnt.val) def not_translatable(self, *nodes): return any( diff --git a/compare_locales/tests/android/test_checks.py b/compare_locales/tests/android/test_checks.py index b7317a0..724cf09 100644 --- a/compare_locales/tests/android/test_checks.py +++ b/compare_locales/tests/android/test_checks.py @@ -148,6 +148,26 @@ def test_missing_placeholder(self): ) +class PrintfSTestNoParamsRef(BaseHelper): + # Check with a reference that is completely missing parameters + file = File("values/strings.xml", "values/strings.xml") + refContent = ANDROID_WRAPPER % b"" + + def test_extra_param(self): + self._test( + ANDROID_WRAPPER % b"%1$s", + (("error", 0, "Formatter %1$s not found in reference", "android"),), + ) + self._test( + ANDROID_WRAPPER % b"%s", + (("error", 0, "Formatter %1$s not found in reference", "android"),), + ) + self._test( + ANDROID_WRAPPER % b"%2$S", + (("error", 0, "Formatter %2$S not found in reference", "android"),), + ) + + class PrintfCapSTest(BaseHelper): file = File("values/strings.xml", "values/strings.xml") refContent = ANDROID_WRAPPER % b"%S" From 3f7762ad9c189f319356ec5784a89b06d4826600 Mon Sep 17 00:00:00 2001 From: Francesco Lodolo Date: Sun, 30 Jun 2024 08:52:10 +0200 Subject: [PATCH 2/3] Fix duplicated key in plurals.py --- compare_locales/plurals.py | 1 - 1 file changed, 1 deletion(-) diff --git a/compare_locales/plurals.py b/compare_locales/plurals.py index d7fd45a..eaf3889 100644 --- a/compare_locales/plurals.py +++ b/compare_locales/plurals.py @@ -180,7 +180,6 @@ "sw": 1, "szl": 9, "ta": 1, - "ta": 1, "te": 1, "tg": 1, "th": 0, From 31a7c0f3d2e4a53d1b96baf0ed79d384dd466148 Mon Sep 17 00:00:00 2001 From: Francesco Lodolo Date: Sun, 30 Jun 2024 08:52:47 +0200 Subject: [PATCH 3/3] Bump to version 0.9.4 --- compare_locales/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compare_locales/__init__.py b/compare_locales/__init__.py index 045d009..1d89766 100644 --- a/compare_locales/__init__.py +++ b/compare_locales/__init__.py @@ -1 +1 @@ -version = "9.0.3" +version = "9.0.4"