Stirling-PDF/scripts
Ludy c047bdda8c
feat(translations): add command to remove unused translation keys (#5292)
# Description of Changes

This pull request adds a new feature to the translation management
script, allowing users to automatically remove unused translations that
are not present in the `en-GB` (golden truth) file. The update includes
both the implementation in `translation_merger.py` and documentation in
`README.md`. The most important changes are grouped below:

**New Feature: Remove Unused Translations**

* Added a `remove-unused` command to `translation_merger.py`, which
removes translation keys from a target file if they are not present in
the `en-GB` reference. This includes backup support and a CLI interface.
[[1]](diffhunk://#diff-bb7f09f590ccabb456565d52afd66c1421525ddb1b6b65c0985aaab5a3c20ae7R282-R307)
[[2]](diffhunk://#diff-bb7f09f590ccabb456565d52afd66c1421525ddb1b6b65c0985aaab5a3c20ae7R397-R404)
[[3]](diffhunk://#diff-bb7f09f590ccabb456565d52afd66c1421525ddb1b6b65c0985aaab5a3c20ae7R464-R471)
* Implemented helper methods `_delete_nested_key` (for deleting nested
keys and cleaning up empty branches) and `get_unused_keys` (for
identifying unused keys) in the translation merger logic.
[[1]](diffhunk://#diff-bb7f09f590ccabb456565d52afd66c1421525ddb1b6b65c0985aaab5a3c20ae7R117-R139)
[[2]](diffhunk://#diff-bb7f09f590ccabb456565d52afd66c1421525ddb1b6b65c0985aaab5a3c20ae7R156-R166)

**Documentation Updates**

* Updated `README.md` to document the new `remove-unused` command and
describe its purpose and usage.
[[1]](diffhunk://#diff-aeee54608ec45b06f4d52a4afcfbc7e6b08dee75f4328207cec32b8ca02fe0c6R185-R187)
[[2]](diffhunk://#diff-aeee54608ec45b06f4d52a4afcfbc7e6b08dee75f4328207cec32b8ca02fe0c6R196)

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
2025-12-25 23:24:30 +00:00
..
translations feat(translations): add command to remove unused translation keys (#5292) 2025-12-25 23:24:30 +00:00
analyze_pdf_json.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
build-tauri-jlink.bat Desktop Self-hosted guidance improvements (#5060) 2025-11-28 15:55:37 +00:00
build-tauri-jlink.sh Desktop Self-hosted guidance improvements (#5060) 2025-11-28 15:55:37 +00:00
convert_cff_to_ttf.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
counter_translation_v3.py V1 merge (#5193) 2025-12-21 10:40:32 +00:00
download_pdf_samples.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
download-security-jar.sh
generate_requirements.bat V1 merge (#5193) 2025-12-21 10:40:32 +00:00
harvest_type3_fonts.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
ignore_translation.toml V1 merge (#5193) 2025-12-21 10:40:32 +00:00
index_type3_catalogue.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
init-without-ocr.sh V1 merge (#5193) 2025-12-21 10:40:32 +00:00
init.sh V1 merge (#5193) 2025-12-21 10:40:32 +00:00
installFonts.sh
PropSync.java
remove_translation_keys.sh
replace_translation_line.sh refactor: move modules under app/ directory and update file paths (#3938) 2025-07-14 20:53:11 +01:00
RestartHelper.java
summarize_type3_signatures.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
type3_to_cff.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00
update_type3_library.py 🤖 format everything with pre-commit by stirlingbot (#5144) 2025-12-22 15:44:38 +00:00