Skip to content

refactor: modernize translation workflow and integrate language mappings#5

Open
abdel792 wants to merge 3 commits intonvdaes:l10nfrom
abdel792:l10nImprovements
Open

refactor: modernize translation workflow and integrate language mappings#5
abdel792 wants to merge 3 commits intonvdaes:l10nfrom
abdel792:l10nImprovements

Conversation

@abdel792
Copy link
Copy Markdown

refactor: modernize translation workflow and integrate language mappings

Summary

This PR consolidates and optimizes the translation synchronization workflow between Crowdin and NVDA add-on repositories. It focuses on technical stability, proper handling of all supported languages, and bi-directional synchronization to prevent data loss.

Key Improvements

1. Robust Language Mapping

  • Centralized Configuration: Integrated .github/scripts/languageMappings.json to manage Crowdin-specific language codes.
  • New Helper Script (langCodes.py): Added a dedicated Python script to handle the reverse mapping (Crowdin IDs to local NVDA directory structure). This ensures regional variants (e.g., es-ESes, ar-SAar_SA, sr-CSsr) are handled correctly without manual intervention or directory duplicates.

2. Fixed API Pagination in checkTranslation.py

  • Issue: The previous implementation only retrieved the first 25 results from the Crowdin API.
  • Fix: Rewrote the script to use recursive pagination (looping through offsets). This ensures that languages appearing later in the alphabet (like Turkish tr) are now correctly tracked and scored.

3. Intelligent Bi-directional Sync

  • PO & Documentation Fallback: Updated crowdinSync.ps1 to check the quality of remote translations via the API.
  • Local Upload: If Crowdin has no translation or the quality is below the defined threshold, the script automatically uploads the local legacy .po or .md files to Crowdin. This populates the Crowdin project immediately with existing local work.
  • Smart Selection: Logic improved to compare MD and XLIFF scores, selecting the best available source to update the local readme.md.

4. Enhanced Debugging & Logging

  • Added explicit DEBUG, SUCCESS, and WARNING messages throughout the PowerShell workflow to provide clear logs in GitHub Actions, making it easier to monitor the scoring and conversion process.

Technical Changes

  • Modified: .github/scripts/crowdinSync.ps1
  • Modified: .github/scripts/checkTranslation.py (added pagination and US English logging)
  • Added: .github/scripts/langCodes.py (symmetrical mapping helper)

Special thanks to @nvdaes for the initial mapping implementation and @seanbudd / @wmhn1872265132 for their valuable feedback.

This commit significantly improves the synchronization process between Crowdin
and the local repository, with a primary focus on the integration of the
'languageMappings.json' file originally implemented by @nvdaes.

Key changes include:

- Integrated languageMappings.json: Now used as the source of truth for
  Crowdin-specific language identifiers during the upload process.
- Added langCodes.py: Implemented a symmetrical Python helper to map
  Crowdin export codes back to standard NVDA directory names (e.g.,
  handling 'es-ES' -> 'es', 'ar-SA' -> 'ar_SA', 'sr-CS' -> 'sr').
- Fixed API Pagination: Updated checkTranslation.py to handle recursive
  API calls. This ensures all languages (including those beyond the
  initial 25 results, such as Turkish) are correctly processed and scored.
- Enhanced crowdinSync.ps1:
    * Implemented bi-directional synchronization to upload local legacy
      files (.po and .md) when remote translation quality is low.
    * Added comprehensive debug and success logging for documentation
      conversions (XLIFF/MD) and scoring.
    * Improved decision logic for readme.md updates based on score comparison.

Special thanks to @nvdaes for the mapping implementation.
- Add instructions for requesting developer access to the Crowdin project via the NVDA add-on mailing list.
- Document required GitHub Secrets (crowdinAuthToken and CROWDIN_PROJECT_ID).
- List necessary scripts and workflow files for the translation infrastructure.
- Clarify the initial export and periodic download processes.
@nvdaes
Copy link
Copy Markdown
Owner

nvdaes commented Apr 28, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants