Skip to content

Conversation

@Brijesh-Thakkar
Copy link
Contributor

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

Copilot AI review requested due to automatic review settings December 31, 2025 11:04
@github-actions github-actions bot added dependencies Pull requests that update a dependency file ui Anything that affects the UI javascript Pull requests that update Javascript code labels Dec 31, 2025
Copy link

Copilot AI left a 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:extract to automatically run sorting after extraction
  • Both en.json and de.json translation 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.

@Brijesh-Thakkar Brijesh-Thakkar force-pushed the fix/sort-translation-keys branch from 02072ba to abf2882 Compare December 31, 2025 11:25
@Brijesh-Thakkar Brijesh-Thakkar changed the title Make translation extraction deterministic by sorting keys (#4056) [#4056] Make translation extraction deterministic by sorting keys Dec 31, 2025
@github-actions
Copy link
Contributor

Hello there 👋

We noticed that it's been some time since activity occurred on your pull request 🤔. In order to keep things moving forward, we're marking this PR as stale and giving you 7 days to respond before it's automatically closed ⏰.

Please take a moment to review your pull request and make any necessary updates or changes 👨‍💻. If you need more time or have any questions, please don't hesitate to let us know 💬.

Thank you for your contributions to our project, and we look forward to hearing back from you soon 🙏.

@github-actions github-actions bot added the stale Marks pull requests that are classified as `stale` by our bot. label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code stale Marks pull requests that are classified as `stale` by our bot. ui Anything that affects the UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant