chore(i18n): add linter enforcing alphabetically sorted locale files#3757
Merged
Conversation
Add check_i18n_sorted.py, which fails when any locale JSON file's keys are not sorted alphabetically (recursively, so nested objects are covered). Supports --fix to sort in place. Wire it into the i18n CI workflow alongside the existing parity check, and sort all existing locale files. Generated-By: PostHog Code Task-Id: 7cbf74de-6bf1-45c0-9c8e-c45f94119edc
Contributor
|
Too many files changed for review. ( Bypass the limit by tagging |
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.
Description
Explain the changes or enhancements you are proposing with this pull request.
Adds a linter that enforces the locale JSON files under
frontend/src/locales/**to have their keys sorted alphabetically, so translation files stay consistent and diffs stay clean.frontend/src/locales/check_i18n_sorted.py, mirroring the existingcheck_i18n_locales.py:<locale>/<namespace>.jsonfile and fails (non-zero exit) if keys aren't sorted alphabetically. Sorting is applied recursively, so nested objects (e.g.settings.json) are covered.--fixto sort files in place, emitting Prettier-compatible output (2-space indent, unicode preserved, trailing newline) sotrunk checkdoesn't reflag them..github/workflows/i18n.yml, alongside the existing parity check..claude/skills/frontend-i18n/SKILL.mdand theCLAUDE.mdquick command reference.Verification
python3 frontend/src/locales/check_i18n_sorted.py→ passes.python3 frontend/src/locales/check_i18n_locales.py→ still passes (parity unaffected).npx prettier --check "src/locales/**/*.json"→ clean.trunk checkon changed files → no issues.AI assistance disclosure
This PR was written with AI assistance (PostHog Code / Claude). The linter script, CI wiring, docs updates, and the one-time sort were generated and verified with an agent, then reviewed.
Checklist
Please check all that apply.
Screenshots (if applicable)
N/A (tooling / CI change)
Created with PostHog Code