Skip to content

chore(i18n): add linter enforcing alphabetically sorted locale files#3757

Merged
gantoine merged 2 commits into
masterfrom
posthog-code/i18n-sorted-linter
Jul 16, 2026
Merged

chore(i18n): add linter enforcing alphabetically sorted locale files#3757
gantoine merged 2 commits into
masterfrom
posthog-code/i18n-sorted-linter

Conversation

@gantoine

Copy link
Copy Markdown
Member

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.

  • New frontend/src/locales/check_i18n_sorted.py, mirroring the existing check_i18n_locales.py:
    • Walks every <locale>/<namespace>.json file and fails (non-zero exit) if keys aren't sorted alphabetically. Sorting is applied recursively, so nested objects (e.g. settings.json) are covered.
    • Supports --fix to sort files in place, emitting Prettier-compatible output (2-space indent, unicode preserved, trailing newline) so trunk check doesn't reflag them.
  • Wired into CI: a new "Check locale files are sorted" step in .github/workflows/i18n.yml, alongside the existing parity check.
  • Documented the new command in .claude/skills/frontend-i18n/SKILL.md and the CLAUDE.md quick command reference.
  • Sorted all existing locale files (one-time reorder across all 18 locales). This is pure key ordering, no translation content changed.

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 check on 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.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots (if applicable)

N/A (tooling / CI change)


Created with PostHog Code

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
Copilot AI review requested due to automatic review settings July 16, 2026 02:07
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review. (220 files found, 100 file limit)

Bypass the limit by tagging @greptile-apps to review.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gantoine
gantoine merged commit 5f6bda9 into master Jul 16, 2026
12 checks passed
@gantoine
gantoine deleted the posthog-code/i18n-sorted-linter branch July 16, 2026 11:41
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.

2 participants