Skip to content

Conversation

@Ludy87
Copy link
Collaborator

@Ludy87 Ludy87 commented Oct 31, 2025

Description of Changes

  • What was changed

    • Refactored scripts/counter_translation.py into a more modular CLI tool.
    • Added argument parsing with new flags:
      • --lang/-l to check a single messages_*.properties file.
      • --show-percentage/-sp to print only the numeric percentage (useful for CI).
      • --show-missing-keys/-smk to list untranslated keys for a single language.
    • Introduced main() entrypoint and helper _lang_from_path() for robust language code extraction.
    • Improved comparison logic:
      • Skips header lines, trims values, and tolerates BOM.
      • Treats en_GB/en_US as 100% translated.
      • Tracks and reports missing keys; removes keys from ignore list once translated.
    • Hardened TOML handling:
      • Automatically creates/updates scripts/ignore_translation.toml when absent.
      • convert_to_multiline() normalizes/sorts arrays for stable diffs.
    • README integration:
      • write_readme() updates language badges from computed progress.
    • Added type hints, richer docstrings, usage examples, and clearer console messages.
    • Deduplicates language results and sorts by percentage (desc).
    • Uses consistent UTF-8 and newline handling.
  • Why the change was made

    • Make translation tracking automation-ready (CI pipelines can consume a single number).
    • Reduce manual maintenance of ignore lists and improve deterministic formatting for clean diffs.
    • Provide better developer UX with explicit flags and actionable diagnostics (missing keys).
    • Increase correctness and maintainability via structured code, typing, and clear responsibilities.

Checklist

General

Documentation

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 for more details.
Copilot AI review requested due to automatic review settings October 31, 2025 19:29
@dosubot dosubot bot added size:L This PR changes 100-499 lines ignoring generated files. enhancement New feature or request labels Oct 31, 2025
@stirlingbot stirlingbot bot added the Documentation Improvements or additions to documentation label Oct 31, 2025
Copy link
Contributor

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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation enhancement New feature or request Github size:L This PR changes 100-499 lines ignoring generated files.

1 participant