Repository navigation
feat(i18n): add comprehensive multi-language support (Chinese, Japanese, French, Spanish, German) - #1251
feat(i18n): add comprehensive multi-language support (Chinese, Japanese, French, Spanish, German)#1251NoodleStormno wants to merge 8 commits into
Conversation
…nslation - Implement extensible GNU gettext i18n architecture in Lang.hx - Add automatic DOM localization pipeline in JsTools.parseComponents - Add language selection and persistence in Settings and EditAppSettings dialog - Provide complete Simplified Chinese translation (zh-CN.po) - Add CJK font fallback in app.html - Add TRANSLATION_GUIDE.md for community contributors
… localization - Expand res/lang/zh-CN.po and app/assets/lang/zh-CN.po to 1395 keys with 100% translation coverage (previously 852 keys were empty) - Enhance Lang.localizeDom to traverse all DOM elements, ensuring <option> elements, <div> text, <li>, and <a> tags are fully localized - Add automatic localization to EnumSelect, createValuesSelect, and ContextMenu titles - Support whitespace-normalized key matching to handle multi-line template strings
|
Updated with commit 0ffcdde:
|
Update: Added Japanese, French, Spanish, and German Localization!In addition to Simplified Chinese, this PR now includes complete, high-quality localization catalogs for:
All catalogs have been strictly verified for pure UTF-8 formatting, placeholder consistency (::name::, ::e::), and valid Gettext syntax. Language selection and auto-detection in Settings have also been expanded to support all 6 languages. |
Fix: Prevent Language from Reverting to English during RuntimeBug Description: Resolution:
|
Closes #1250
Summary of Changes
This PR implements a comprehensive, robust, and extensible internationalization (i18n) framework for LDtk and introduces full Simplified Chinese (zh-CN) localization as the first supported non-English language.
The implementation is designed to be completely non-invasive to existing workflows and allows community translators to easily add new languages (Japanese, French, German, Spanish, etc.) via standard GNU gettext
.pofiles.Key Architectural Changes
i18n Core Engine (
Lang.hx):LANGUAGESregistry containing supported language metadata.Lang.setLanguage(lid)supporting both compile-time embedded resources (hxd.Res) and external runtime catalogs (res/lang/*.po,app/assets/lang/*.po).Lang.getText(str, ?vars)with intelligent whitespace normalization for multi-line strings, with graceful fallback to the original English text.Lang.localizeDom(jCtx)to automatically translate text nodes,title,placeholder, and<info>elements.Component Integration (
JsTools.hx, UI Classes):Lang.localizeDom()intoJsTools.parseComponents(), automatically translating all HTML templates on load without modifying their HTML source structure.ContextMenu.hx), modal dialogs (Dialog.hx), notifications (Notification.hx), and tooltips (Tip.hx).Settings & Language Selection (
Settings.hx,EditAppSettings.hx,editAppSettings.html):localefield toAppSettingsto persist the user's language selection.navigator.language(defaults to Chinese on Chinese systems, English on others).Typography & Translations:
res/lang/zh-CN.powith complete Chinese translations for all core features (project settings, layers, entities, tilesets, auto-layer rules, shortcuts, dialogs).res/lang/sourceTexts.potandres/lang/en.po.app.html(Microsoft YaHei, PingFang SC, Noto Sans CJK SC) for smooth typography.Extensibility Documentation:
docs/TRANSLATION_GUIDE.mdexplaining how community members can contribute and add new languages in 2 simple steps.Verification & Testing
haxe main.debug.hxmlandhaxe renderer.debug.hxml(exit code 0).haxe main.hxmlandhaxe renderer.hxml(exit code 0).node --check app/assets/main.jsandnode --check app/assets/js/renderer.js.electron-builderand tested on Windows Electron runtime.