Skip to content

Commit

Permalink
Merge pull request #25 from mozilla/bug1905520
Browse files Browse the repository at this point in the history
Android: flag extra parameters as error when reference has none
  • Loading branch information
eemeli authored Jul 1, 2024
2 parents c772285 + 31a7c0f commit 41e148f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compare_locales/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "9.0.3"
version = "9.0.4"
4 changes: 2 additions & 2 deletions compare_locales/checks/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion compare_locales/plurals.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
"sw": 1,
"szl": 9,
"ta": 1,
"ta": 1,
"te": 1,
"tg": 1,
"th": 0,
Expand Down
20 changes: 20 additions & 0 deletions compare_locales/tests/android/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 41e148f

Please sign in to comment.