-
-
Notifications
You must be signed in to change notification settings - Fork 405
New helper script for translations #2948
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: develop
Are you sure you want to change the base?
New helper script for translations #2948
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.
PR Summary:
This PR adds helper scripts to facilitate translation workflows for pyRevit extension bundles. The scripts enable:
- Extraction of title/tooltip fields from YAML files to CSV for translation
- Application of translated values back to YAML files
- Support for multiple languages including Chinese Simplified
The tools aim to streamline the community translation efforts discussed in the discourse forum.
Review Summary:
Reviewed the translation helper scripts for logic correctness, data integrity, and error handling. Found one critical logic bug where path information is lost during CSV processing, causing incorrect behavior with nested YAML structures. Also identified a high-severity file corruption risk when write operations fail. The code follows Black formatting and PEP8 conventions as required.
Knowledge utilized: Exception handling standards from the review checklist emphasizing specific exception types over broad catching.
Follow-up suggestions:
@devloai fix the path information bug in comment #1- Fix the critical logic issue with nested structures@devloai add a README to extras/bundle_translations/- Document the workflow and usage for future translators
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 two Python helper scripts to facilitate translation workflows for pyRevit bundle YAML files. The scripts enable extraction of translatable strings (titles and tooltips) to CSV format and reimportation of completed translations back to the YAML files.
- Introduces
extract_translations.pyto scan bundle YAML files and export translatable content to CSV - Adds
apply_translations.pyto read translated CSV files and update YAML files with new translations - Supports configurable source and target languages with focus on Chinese (Simplified) support
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| extras/bundle_translations/extract_translations.py | Extracts title and tooltip fields from YAML files recursively, handling both multilingual dictionaries and scalar values, outputting to CSV |
| extras/bundle_translations/apply_translations.py | Reads translations from CSV and applies them to YAML files, converting scalar fields to multilingual dictionaries as needed |
Description
adds a new helper script to extract all titles and tooltips. language and folder can be changed in code. reimport of csv possible.
Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Related Issues
If applicable, link the issues resolved by this pull request:
https://discourse.pyrevitlabs.io/t/inquiry-about-chinese-simplified-language-support/9624/3
Additional Notes
Include any additional context, screenshots, or considerations for reviewers.
Thank you for contributing to pyRevit! 🎉