-
Notifications
You must be signed in to change notification settings - Fork 5.9k
feat(scripts): enhance translation progress tool with CLI flags, TOML management, and CI-friendly output #4801
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: main
Are you sure you want to change the base?
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 significantly refactors the translation counter script to improve documentation, add command-line argument support, and enhance maintainability. The script now supports checking individual language files and offers CI/CD-friendly output modes.
- Added argparse-based CLI with options for single file checking and percentage-only output
- Refactored main logic into a
main()function and extracted language parsing to_lang_from_path() - Enhanced documentation with comprehensive docstrings and usage examples
Comments suppressed due to low confidence (1)
scripts/counter_translation.py:199
- File is not explicitly closed. Use a context manager (
with open(...)) to ensure proper resource cleanup.
num_lines = sum(
1
for line in open(default_file_path, encoding="utf-8")
if line.strip() and not line.strip().startswith("#")
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaces calls to the built-in exit() function with sys.exit() for more explicit and reliable script termination. This change improves clarity and ensures consistent behavior when exiting due to errors.
Added docs/counter_translation.md to document the usage and requirements of the counter_translation.py script. Updated the pull request template to include a checklist item for running the translation counter script when translations are changed.
Description of Changes
What was changed
scripts/counter_translation.pyinto a more modular CLI tool.--lang/-lto check a singlemessages_*.propertiesfile.--show-percentage/-spto print only the numeric percentage (useful for CI).--show-missing-keys/-smkto list untranslated keys for a single language.main()entrypoint and helper_lang_from_path()for robust language code extraction.en_GB/en_USas 100% translated.scripts/ignore_translation.tomlwhen absent.convert_to_multiline()normalizes/sorts arrays for stable diffs.write_readme()updates language badges from computed progress.Why the change was made
Checklist
General
Documentation
UI Changes (if applicable)
Testing (if applicable)