Skip to content

refactor(i18n): Sort i18n keys in translation files to match English ordering #4572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

hassoncs
Copy link

@hassoncs hassoncs commented Jun 11, 2025

Description

Reorder keys in all i18n json files to maintain consistent ordering that matches the 'en' locale. This improves readability and maintainability of the translation files without changing any behavior. I'm happy to close this PR if you think this a bad idea! Just thought I'd propose it :)

Dev notes

I sorted the keys programmatically using Node, not by hand, so there shouldn't be anything missing or out of place!

Test Procedure

No strings have been removed, so the tests should catch any missing strings!

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Important

Refactors i18n JSON files by sorting keys to match the 'en' locale, improving readability and maintainability without changing behavior.

  • Behavior:
    • Sorts keys in all i18n JSON files to match the 'en' locale, improving readability and maintainability.
    • No changes to string content or functionality.
  • Files Affected:
    • ca/chat.json, de/chat.json, es/chat.json ... and 18 other files.
  • Misc:
    • Ensures consistent ordering across all translation files.

This description was created by Ellipsis for 2bcdfe6. You can customize this summary. It will automatically update as commits are pushed.

@hassoncs hassoncs requested review from mrubens, cte and jr as code owners June 11, 2025 21:25
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jun 11, 2025
@hassoncs hassoncs changed the title refactor(i18n): Sort settings keys in translation files refactor(i18n): Sort i18n keys in translation files to match Jun 11, 2025
@hassoncs hassoncs changed the title refactor(i18n): Sort i18n keys in translation files to match refactor(i18n): Sort i18n keys in translation files to match English ordering Jun 11, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 11, 2025
Reordered keys in all tranlation json files to maintain consistent ordering that matches the 'en' locale. This improves readability and maintainability of the translation files.
@hassoncs hassoncs force-pushed the sort-settings-keys branch from 2bcdfe6 to d094cc3 Compare June 11, 2025 21:43
hassoncs added 2 commits June 11, 2025 16:53
There were a bunch of inconsistencies revealed when I ran the linting script, so I fixed them!
Adds a new CI step to verify that all locale files maintain the same key ordering as their corresponding English locale files. This helps ensure consistency across all committed translations and prevents accidental reordering going forward

The new `lint-locale-key-ordering.js` script checks both backend (`src/i18n/locales`) and frontend (`webview-ui/src/i18n/locales`) translation files. It identifies missing keys, extra keys, and keys that are out of order compared to the English reference.

This linter will run as part of the `code-qa` workflow.
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Jun 11, 2025
@hassoncs
Copy link
Author

I added a commit that adds a linter to try to maintain the ordering. It revealed that there were actually a bunch of mis-matched strings between english and the other locales, so I fixed those too!

}
"input": {
"task_prompt": "Què vols que faci Roo?",
"task_placeholder": "Escriu la teva tasca aquí"
}
Copy link
Author

Choose a reason for hiding this comment

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

These keys live in settings.json now, they must have be left here at some point!

}

console.log(
`\n${area === "core" ? "BACKEND" : "FRONTEND"} - Checking key ordering for ${locales.length} locale(s): ${locales.join(", ")}`,
Copy link
Author

Choose a reason for hiding this comment

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

vibe fix- just say "core" or "webview", not "BACKEND" / "FRONTEND"

Refactor the `lint-locale-key-ordering.js` script to enhance readability and provide more concise output.

- Updated help message for clarity and brevity.
- Simplified key extraction logic to directly push keys.
- Streamlined issue reporting for missing, extra, and out-of-order keys.
- Improved console logging for better user experience.
- Removed redundant comments and simplified function descriptions.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 12, 2025
@daniel-lxs
Copy link
Collaborator

Hey @hassoncs, we really appreciate your contribution!

Just a quick thought. This is quite a significant change, and I’m a bit concerned it might introduce a lot of conflicts in most PRs that touch translations. Given that we already have a translation mode that really helps with adding new translations and a script to handle missing ones, it might not be needed to go this route.

That said, happy to discuss it further if you have other thoughts!

@daniel-lxs daniel-lxs closed this Jun 12, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
@hassoncs
Copy link
Author

hassoncs commented Jun 12, 2025

@daniel-lxs, that's a very good point! Do you think if the lint script could fix the ordering instead of just error-ing out, then users with open PRs could run the script which would solve the conflicts in the short-term? Then the linter will keep things in sync going forward?

@daniel-lxs
Copy link
Collaborator

@hassoncs
To be honest, most of the conflicts will probably have to be solved by me, sometimes is hard for a contributor to find time and fix problems on their PR, that's perfectly understandable since they are volunteers, so I like to jump in and get their PR over the finish line.

I'm not against adding a script to order the i18n files at all, but I think we should have a pretty good reason to create all the extra work that it requires.

@hassoncs
Copy link
Author

@daniel-lxs, ah yeah, I see what you are saying! Keeping them ordered is just another thing for contributors to worry about. It does make it a lot easier to see when locales have mismatches– this PR revealed a bunch of strings that the find-missing script seems to have missed. I'll open a PR with just those targeted string changes if that's ok!

Thanks for taking the time to explain! I'll keep this branch around if you ever change your mind haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants