-
-
Notifications
You must be signed in to change notification settings - Fork 50
feat: Add translation tag checker for issue #1102 #1997
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: master
Are you sure you want to change the base?
Conversation
--> Add check_translations.py script to detect missing, untranslated, and empty T0xxx tags --> Added comprehensive pytest tests for translation validation --> Updatd run-tests-generate-output.yaml to run checker and include report in PR comments --> Updated pre-release.yml to include translation report in release body --> Resolved missing tag detection as requested in OWASP#1102
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 adds a translation tag checker to validate that translation files contain all the same T0xxx tags as English versions, addressing issue #1102. The implementation includes a Python script for tag validation, integration tests, and GitHub Actions workflow integration for automated checking on PRs and pre-releases.
Key Changes:
- New translation checker script that validates tag completeness across all language files
- Automated test suite with 6 tests covering tag validation, format checking, and duplicate detection
- GitHub Actions integration to post translation reports as PR comments and include them in pre-release notes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
scripts/check_translations.py |
Core translation checker that extracts T0xxx tags from YAML files and compares translations against English reference |
tests/scripts/test_translation_tags.py |
Integration tests validating translation completeness, tag format (T0xxxx pattern), and duplicate detection |
.github/workflows/run-tests-generate-output.yaml |
Runs translation checker on PRs, uploads report as artifact, and posts results as PR comment |
.github/workflows/pre-release.yml |
Integrates translation check into pre-release workflow and includes report in release body |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@sydseter I addressed the feedback and updated the PR. If anything still looks off, please point it out and I’ll fix it promptly. |
| def setUp(self): | ||
| """Set up test fixtures.""" | ||
| # Navigate up from tests/scripts to cornucopia root | ||
| self.base_path = Path(__file__).parent.parent.parent |
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.
Set it to read from this dir: https://github.com/OWASP/cornucopia/tree/master/tests/test_files
And create mock yaml files there that you can test against. There are some there already, but you should create a new translation file that verifies that the script can indeed find translation issues.
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.
I will look into this
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.
This still need to be done.
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.
Is still not done for: check_translations_itest.py
|
@sydseter sorry for not notifying you fast (2 week ago), I had already implemented everything you suggested can you check the pr and tell me if its good to go or I need to do some other changes !! |
|
@immortal71 look at my comments and please merge in the latest changes from master before continuing. |
|
Please update your branch against master before continuing |
…fy mock files work correctly
6cddfa8 to
3603503
Compare
|
@sydseter |
| def setUp(self): | ||
| """Set up test fixtures.""" | ||
| # Navigate up from tests/scripts to cornucopia root | ||
| self.base_path = Path(__file__).parent.parent.parent |
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.
This still need to be done.
| def setUp(self): | ||
| """Set up test fixtures.""" | ||
| # Navigate up from tests/scripts to cornucopia root | ||
| self.base_path = Path(__file__).parent.parent.parent |
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.
Is still not done for: check_translations_itest.py
|
convert_utest.py is failing |
|
Remember to run all tests before pushing the result |
Description
This PR implements a comprehensive translation tag checker to address issue #1102. The solution automatically validates that translation files contain all the same T0xxx tags as the English version, and detects common translation issues.
Changes Made
1. Translation Checker Script (
scripts/check_translations.py)2. Automated Tests (
tests/scripts/test_translation_tags.py)3. GitHub Actions Integration
Pull Request Workflow (
run-tests-generate-output.yaml)Pre-Release Workflow (
pre-release.yml)body_pathHow It Works
For Pull Requests: When source files change, the workflow:
For Pre-Releases: On master branch pushes:
Example Output
Testing
All tests pass locally:
pytest tests/scripts/test_translation_tags.py -v # 6 passed in 4.84sThe script correctly identifies translation issues and generates readable reports.
Copilot Review Feedback Addressed
[x] Fixed language code mappings (
no-nb,pt-br,pt-ptinstead of underscores)[x] Removed unused imports (
os,Set,Tuple)[x] All Copilot feedback for translation checker files addressed
Benefits
[x] Automatically catches missing translations before release
[x] Identifies untranslated content (identical to English)
[x] Detects empty tag values
[x] Works seamlessly with existing CI/CD pipelines
[x] Provides clear, actionable reports for translators
[x] Zero manual intervention required
Related Issue
Closes #1102