Skip to content

Skip Android UI-mode values-* qualifier dirs (e.g. values-car) when pruning#747

Open
oguzkocer wants to merge 1 commit into
add/prune-orphaned-translationsfrom
fix/prune-skip-ui-mode-qualifiers
Open

Skip Android UI-mode values-* qualifier dirs (e.g. values-car) when pruning#747
oguzkocer wants to merge 1 commit into
add/prune-orphaned-translationsfrom
fix/prune-skip-ui-mode-qualifiers

Conversation

@oguzkocer

Copy link
Copy Markdown
Contributor

Heads up: this is a solution that passes the regression test and is correct for WordPress-Android, but I don't have full context on GlotPress export conventions or every consuming app. Happy for someone with more context (@wordpress-mobile/apps-infra-tooling) to take over or steer this differently.

The situation

#746 (by @mokagio, already merged into this branch) added a regression test showing that android_prune_orphaned_translations treats values-car as a locale and would prune its resources. That test currently fails on this branch.

Root cause: the locale-detection regex's 2–3 letter language branch ([a-z]{2,3}) matches car. But values-car is the Android UI-mode qualifier (docs), not a locale. The catch is that car is also a valid 3-letter ISO 639 language code, so there's no purely syntactic way for a regex to tell values-car-the-UI-mode from values-car-the-language — Android itself can't either.

What this PR does

  • Keeps the 2–3 letter locale grammar and explicitly excludes Android's documented UI-mode qualifiers via a UI_MODE_QUALIFIERS list. In practice car is the only one short enough to collide today; the rest are listed to capture the documented set.
  • Adds a values-kmr (Northern Kurdish) test so 3-letter legacy locales keep getting pruned.

Alternatives considered

  • Restrict legacy locales to 2 letters — simpler, but rejected: WordPress-Android ships values-kmr, a real 3-letter legacy locale that must still be pruned. A 2-letter rule would silently skip it.
  • Validate against a real ISO 639 language list — doesn't help: car is a valid ISO 639 code, so a language list would still classify values-car as a locale.

Open question (not a blocker)

Could the GlotPress → Android export ever emit other folder names that collide with a non-locale qualifier? If so, we'd just extend the same exclusion list. Confirming the export's folder-naming conventions separately; not a blocker for WordPress-Android (no values-car).

Notes

The locale-detection regex's 2-3 letter language branch also matches
Android UI-mode qualifiers like `values-car`, which would prune valid
car-mode resources. `car` is also a valid 3-letter ISO 639 language
code and cannot be distinguished from a locale by shape alone, so
exclude the documented UI-mode qualifiers explicitly.

Changes:
- Add UI_MODE_QUALIFIERS exclusion list and apply it in locale detection
- Add a values-kmr test covering 3-letter legacy locales
- Note locale-only scope in the CHANGELOG entry
@oguzkocer oguzkocer requested a review from a team as a code owner June 29, 2026 16:57
@oguzkocer oguzkocer requested a review from mokagio June 29, 2026 16:58
@dangermattic

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ Please add an entry in the CHANGELOG.md file to describe the changes made by this PR
⚠️ No reviewers have been set for this PR yet. Please request a review from @⁠wordpress-mobile/apps-infrastructure.

Generated by 🚫 Danger

@mokagio mokagio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for following up on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants