Require other in pluralized default translations - #1292
Open
agustinpabon wants to merge 1 commit into
Open
Conversation
Author
|
I have signed the CLA! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you adding in this PR?
Add a
requireOtheroption toMatchingTranslations, enabled by default, to report recognized pluralized entries missingotherin storefront default locale files.Fixes #452.
For example, this entry in
locales/en.default.jsonnow produces a diagnostic:{ "items": { "one": "One item" } }Reports:
The pluralized translation 'items' is missing the 'other' key.Adding an
othertranslation resolves that diagnostic. SettingMatchingTranslations.requireOther: falsedisables only the new requirement and preserves the existing missing/extra translation checks:Detection is intentionally conservative: it recognizes non-empty objects whose immediate members are exact plural-category names with string values. Mixed namespaces and non-string structures are not treated as pluralization objects.
The change leaves schema locales and plural-category differences in other languages unchanged. It preserves external namespace exemptions and reports the affected property without inventing translation content or offering an automatic fix.
This intentionally adds a new default-on lint diagnostic. Themes with affected entries may need to add
otheror disable this requirement.What's next? Any followup issues?
A Shopify maintainer may need to update the internal shopify.dev documentation for
MatchingTranslationsto describerequireOther, its default, and its storefront-only scope. That internal documentation update has not been performed in this PR.Tophatting
For manual verification, use a storefront default locale containing
{"items":{"one":"One item"}}. The rule should report the missingotherentry. Addingotheror settingrequireOther: falseshould remove only that new diagnostic; existing missing/extra translation checks should remain active.Automated validation
Recorded on Windows with Node 24.19.0 and the checkout's pnpm 10.16.1:
pnpm exec vitest run packages/theme-check-common/src/checks/matching-translations/index.spec.tson the baseline with the new regression testotherwith the correct file, message and property range.pnpm exec vitest run packages/theme-check-common/src/checks/matching-translations/index.spec.ts packages/theme-check-node/src/config/load-config.spec.tspnpm exec vitest run packages/theme-check-common packages/theme-check-nodepnpm buildpnpm type-checkpnpm format:checkpnpm exec prettier --check .changeset/plural-translations-require-other.md packages/theme-check-node/configs/all.yml packages/theme-check-node/configs/recommended.ymlgit diff --checkandgit diff --check 65fd7743556a6fcb554f08fa58ee13a080a65b07 HEADThe full monorepo unit suite, complete platform matrix, browser E2E and live-store integration were not run. Successful local validation was not repeated solely for publication.
Before you deploy
@shopify/theme-check-commonand@shopify/theme-check-node.pnpm buildand committed generatedall.ymlandrecommended.ymlupdates withrequireOther: true.theme-app-extension.ymlinherits the recommended configuration; no override is needed.AI assistance
OpenAI Codex assisted with implementation and validation. The contributor personally reviewed the diff and diagnostic examples before submission.