Add automated i18n string extraction tool with translations#37
Conversation
|
@copilot Hi, if you take a note, in |
Fixed in commit 62148e0. The script now strips |
Nidrax
left a comment
There was a problem hiding this comment.
Remove any implicit referenes to Besprite or Veritaware from readmes and scripts, so the solution can be later backported to LibrSprite project
|
|
||
| 3. **Copy the output**: The logged strings are already in the correct JSON format and can be copied directly into the language files. | ||
|
|
||
| 4. **Re-run the static tool**: After adding any manual entries, run `update_i18n.py` again to ensure all files are synchronized and alphabetically sorted. |
There was a problem hiding this comment.
Is it ensured that update_i18n.py will not delete any already existing entries from the .json it could not find in the sources itself?
There was a problem hiding this comment.
Yes, the script only adds missing entries and never deletes existing ones. See lines 147-151 in update_i18n.py: it checks if string not in translations before adding. This is now explicitly documented in the README.
tools/update_i18n.sh
Outdated
There was a problem hiding this comment.
Remove the file and just update the readme with the information to run the python script from the repo base folder.
There was a problem hiding this comment.
Done in commit ace8e8d. Removed the shell wrapper and updated README to show running python3 tools/update_i18n.py from the repository root.
Done in commit ace8e8d. Removed all references to Besprited and Veritaware from scripts and documentation. |
52ab1d0 to
89021a0
Compare
|
@copilot Analyze changes in translations |
Co-authored-by: Nidrax <4753308+Nidrax@users.noreply.github.com>
Done in commit 8c42468. Added professional translations for 110+ new keys in German, Spanish, French, Italian, Portuguese, Russian, and Polish. Translations use standard graphics editor terminology appropriate for pixel art software. Languages with non-Latin scripts (Arabic, Hindi, Indonesian, Japanese, Korean, Chinese) retain English values pending native speaker review. |
…el cebolla Co-authored-by: Nidrax <4753308+Nidrax@users.noreply.github.com>
* Add i18n extraction tool * Update CodeQL workflow to analyze Python scripts * Add translations for new i18n keys Co-authored-by: Daniel Praźmo <d.prazmo@icloud.com>
Automates extraction of translatable strings from C++ sources and XML widgets into language JSON files, with professional translations for major European languages. Developers previously had to manually maintain 14 language files when adding UI text.
This tool is designed to be product-agnostic and portable, making it suitable for backporting to LibreSprite and other projects.
Implementation
String Extraction
app::i18n("text")callstextattributes fromdata/widgets/*.xmlanddata/gui.xml&characters from XML text attributes to matchWidget::setI18N()behavior which removes ampersands before using text as i18n keysLanguage File Updates
data/languages/*.jsonfiles"key": "key"for translator workflowTranslations Included
Usage
python3 tools/update_i18n.py # Run from repository rootPython 3 stdlib only, no external dependencies. Extracts 464 unique strings (462 XML, 2 C++).
Files Added
tools/update_i18n.py- Main extraction logic with ampersand stripping (product-agnostic)tools/README.md- Usage and runtime DEBUG workflow documentation (product-agnostic)Files Modified
data/languages/{de,es,fr,it,pt,ru,pl}.json- Added 728 professional translations across 7 languages, with Spanish translation corrections for proper orthography and terminology consistencyTechnical Details
The tool correctly handles XML keyboard shortcut indicators (e.g.,
<button text="&OK">) by stripping the&character before adding to language files, matching the behavior ofWidget::setI18N()insrc/ui/widget.cppwhich removes ampersands before i18n key lookup. This ensures keys are stored as"OK"rather than"&OK", preventing duplicate entries and preserving existing translations.All product-specific references have been removed from the tool and documentation to facilitate backporting to LibreSprite and other projects.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.