mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-02-01 20:10:35 +01:00
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## 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) ### 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. --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> Signed-off-by: stirlingbot[bot] <stirlingbot[bot]@users.noreply.github.com> Co-authored-by: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com> Co-authored-by: Connor Yoh <connor@stirlingpdf.com> Co-authored-by: OUNZAR Aymane <aymane.ounzar@imt-atlantique.net> Co-authored-by: YAOU Reda <yaoureda24@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> Co-authored-by: Balázs Szücs <127139797+balazs-szucs@users.noreply.github.com> Co-authored-by: Ludy <Ludy87@users.noreply.github.com> Co-authored-by: tkymmm <136296842+tkymmm@users.noreply.github.com> Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org> Co-authored-by: albanobattistella <34811668+albanobattistella@users.noreply.github.com> Co-authored-by: PingLin8888 <88387490+PingLin8888@users.noreply.github.com> Co-authored-by: FdaSilvaYY <FdaSilvaYY@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: OteJlo <106060728+OteJlo@users.noreply.github.com> Co-authored-by: Angel <41905618+TheShadowAngel@users.noreply.github.com> Co-authored-by: Ricardo Catarino <ricardomicc@gmail.com> Co-authored-by: Luis Antonio Argüelles González <luis.arguelles@encora.com> Co-authored-by: Dawid Urbański <31166488+urbaned121@users.noreply.github.com> Co-authored-by: Stephan Paternotte <Stephan-P@users.noreply.github.com> Co-authored-by: Leonardo Santos Paulucio <leonardo.paulucio@hotmail.com> Co-authored-by: hamza khalem <72972114+hamzakhalem@users.noreply.github.com> Co-authored-by: IT Creativity + Art Team <admin@it-playground.net> Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> Co-authored-by: James Brunton <jbrunton96@gmail.com> Co-authored-by: Victor Villarreal <133383186+vvillarreal-cfee@users.noreply.github.com>
65 lines
2.8 KiB
Markdown
65 lines
2.8 KiB
Markdown
# `counter_translation.py`
|
||
|
||
## Overview
|
||
|
||
The script [`scripts/counter_translation.py`](../scripts/counter_translation.py) checks the translation progress of the property files in the directory `app/core/src/main/resources/`.
|
||
It compares each `messages_*.properties` file with the English reference file `messages_en_GB.properties` and calculates a percentage of completion for each language.
|
||
|
||
In addition to console output, the script automatically updates the progress badges in the project’s `README.md` and maintains the configuration file [`scripts/ignore_translation.toml`](../scripts/ignore_translation.toml), which lists translation keys to be ignored for each language.
|
||
|
||
## Requirements
|
||
|
||
- Python 3.10 or newer (requires `tomlkit`).
|
||
- Must be executed **from the project root directory** so all relative paths are resolved correctly.
|
||
- Write permissions for `README.md` and `scripts/ignore_translation.toml`.
|
||
|
||
## Default usage
|
||
|
||
```bash
|
||
python scripts/counter_translation.py
|
||
```
|
||
|
||
This command:
|
||
|
||
1. scans `app/core/src/main/resources/` for all `messages_*.properties` files,
|
||
2. calculates the translation progress for each file,
|
||
3. updates the badges in `README.md`,
|
||
4. reformats `scripts/ignore_translation.toml` (sorted, multi-line arrays).
|
||
|
||
## Check a single language
|
||
|
||
```bash
|
||
python scripts/counter_translation.py --lang messages_fr_FR.properties
|
||
```
|
||
|
||
- The specified file can be given as a relative (to the resources folder) or absolute path.
|
||
- The result is printed to the console (e.g. `fr_FR: 87% translated`).
|
||
- With `--show-missing-keys`, all untranslated keys are listed as well.
|
||
|
||
## Output only the percentage
|
||
|
||
For scripts or CI pipelines, the output can be reduced to just the percentage value:
|
||
|
||
```bash
|
||
python scripts/counter_translation.py --lang messages_fr_FR.properties --show-percentage
|
||
```
|
||
|
||
The console will then only print `87` (without the percent symbol or any extra text).
|
||
|
||
## Handling `ignore_translation.toml`
|
||
|
||
- If a language section is missing, the script creates it automatically.
|
||
- Entries in `ignore` are alphabetically sorted and written as multi-line arrays.
|
||
- By default, `language.direction` is ignored. If that key is later translated, the script automatically removes it from the ignore list.
|
||
|
||
## Integration in Pull Requests
|
||
|
||
Whenever translations are updated, this script should be executed.
|
||
The updated badges and the modified `ignore_translation.toml` should be committed together with the changed `messages_*.properties` files.
|
||
|
||
## Troubleshooting
|
||
|
||
- **File not found**: Check the path or use `--lang` with an absolute path.
|
||
- **Line error**: The script reports the specific line in both files—this usually means a missing `=` or an unmatched line.
|
||
- **Incorrect percentages in README**: Make sure the script was run from the project root and that write permissions are available.
|