chore: localization protection#282
Open
camrun91 wants to merge 9 commits into
Open
Conversation
|
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.
This adds ci, lint, and greptile rules to help gaurd against hardcoded strings.
Greptile Summary
This PR establishes the localization protection layer for
@youversion/platform-react-ui: a CI locale-ownership gate, a static i18n parity check script, an ESLint rule for hardcoded strings, and documentation — plus immediately fixes four hardcoded aria-label/sr-only strings inbible-reader.tsxandpopover.tsxusing new keys already added toen.json.locale-ownership,i18n-check): the ownership script now correctly requires both bot-author AND branch-prefix conditions simultaneously, closing both bypass vectors from the previous review. The parity script hard-fails only on structurally invalid states and warns on orphan/untranslated keys.i18next/no-literal-string): scoped topackages/ui/src/components/**/*.tsx,mode: 'jsx-only', checkingaria-label,title,placeholder, andalt; tests and stories excluded.decreaseFontSizeAriaLabel,increaseFontSizeAriaLabel,changeLineSpacingAriaLabel,closeAriaLabel) are present inen.jsonand consumed viat()consistent with existing patterns.Confidence Score: 5/5
Safe to merge — all three protection layers are consistent with each other and the documentation, and the component fixes are backed by keys already in en.json.
The ownership script correctly enforces both conditions simultaneously, the parity script fails only on provably broken states, the ESLint rule is appropriately scoped, and the four component fixes are immediately verifiable against en.json. No functional regressions or data-loss paths were identified.
tools/eslint-config/index.js — the mode: 'jsx-only' configuration has a narrow gap for expression-wrapped string literals that the rule does not currently catch.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD PR[Pull Request opened] --> LO{locale-ownership job pull_request only} PR --> I18N[i18n-check job all pushes and PRs] PR --> LINT[lint job] LO --> BOT{is_sync_bot_author? AND is_sync_branch?} BOT -->|Yes - both true| SKIP[Skip check] BOT -->|No - either false| CHANGED{Locale files changed?} CHANGED -->|No| PASS1[Pass] CHANGED -->|Yes| FAIL1[Fail - Locale files are upstream-owned] I18N --> PARITY[check-i18n-parity.mjs] PARITY --> MISSING{Keys used in source missing from en.json?} MISSING -->|Yes| FAIL2[Fail] MISSING -->|No| EXTRA{Extra keys in fr/es not in en?} EXTRA -->|Yes| FAIL2 EXTRA -->|No| TOKEN{Interpolation token mismatch?} TOKEN -->|Yes| FAIL2 TOKEN -->|No| WARN[Warn only - missing fr/es keys, orphan en keys] WARN --> PASS2[Pass with warnings] LINT --> ESLINT[eslint-plugin-i18next no-literal-string] ESLINT --> SCOPE[packages/ui/src/components/**/*.tsx excluding test and stories] SCOPE --> HARDCODE{Hardcoded string in JSX text or aria-label/title/placeholder/alt?} HARDCODE -->|Yes| FAIL3[Fail] HARDCODE -->|No| PASS3[Pass]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD PR[Pull Request opened] --> LO{locale-ownership job pull_request only} PR --> I18N[i18n-check job all pushes and PRs] PR --> LINT[lint job] LO --> BOT{is_sync_bot_author? AND is_sync_branch?} BOT -->|Yes - both true| SKIP[Skip check] BOT -->|No - either false| CHANGED{Locale files changed?} CHANGED -->|No| PASS1[Pass] CHANGED -->|Yes| FAIL1[Fail - Locale files are upstream-owned] I18N --> PARITY[check-i18n-parity.mjs] PARITY --> MISSING{Keys used in source missing from en.json?} MISSING -->|Yes| FAIL2[Fail] MISSING -->|No| EXTRA{Extra keys in fr/es not in en?} EXTRA -->|Yes| FAIL2 EXTRA -->|No| TOKEN{Interpolation token mismatch?} TOKEN -->|Yes| FAIL2 TOKEN -->|No| WARN[Warn only - missing fr/es keys, orphan en keys] WARN --> PASS2[Pass with warnings] LINT --> ESLINT[eslint-plugin-i18next no-literal-string] ESLINT --> SCOPE[packages/ui/src/components/**/*.tsx excluding test and stories] SCOPE --> HARDCODE{Hardcoded string in JSX text or aria-label/title/placeholder/alt?} HARDCODE -->|Yes| FAIL3[Fail] HARDCODE -->|No| PASS3[Pass]Reviews (8): Last reviewed commit: "fix: bypass not matching" | Re-trigger Greptile
Context used (3)