-
Notifications
You must be signed in to change notification settings - Fork 217
[#4056] Make translation extraction deterministic by sorting keys #4080
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
base: dev
Are you sure you want to change the base?
[#4056] Make translation extraction deterministic by sorting keys #4080
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses issue #4056 by introducing deterministic sorting for translation files. The change adds a post-processing script that alphabetically sorts translation JSON keys after extraction, preventing noisy diffs and merge conflicts.
Key changes:
- New Node.js script (
sort-translations.js) to sort translation keys alphabetically - Updated npm script
i18n:extractto automatically run sorting after extraction - Both
en.jsonandde.jsontranslation files have been re-sorted alphabetically
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| ui/scripts/sort-translations.js | New utility script that reads, sorts, and writes JSON translation files |
| ui/package.json | Updated i18n:extract command to chain the new sorting script after extraction |
| ui/deployment/i18n/en.json | Translation keys sorted alphabetically (values unchanged) |
| ui/deployment/i18n/de.json | Translation keys sorted alphabetically (values unchanged) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a1d8491 to
02072ba
Compare
02072ba to
abf2882
Compare
|
Hello there 👋 |
Purpose
This PR addresses issue #4056 by making the translation extraction process less error-prone through deterministic sorting of extracted translation keys.
Currently, ngx-translate-extract merges newly extracted keys into existing translation files without guaranteeing a stable key order. This often leads to noisy diffs and merge conflicts when translation strings are added or modified.
To resolve this, a small post-processing step was introduced that consistently sorts the generated translation JSON files alphabetically by key after extraction.
The change does not modify any translation values or extraction behavior; it only ensures stable and reproducible output.
Remarks
The solution is intentionally minimal and avoids changes to the extraction logic itself.
No additional dependencies were introduced.
The resulting changes consist solely of key reordering; translation values remain unchanged.
This improves maintainability and reduces merge conflicts when working with translation files.
PR introduces (a) breaking change(s): no
PR introduces (a) deprecation(s): no