Tool to speed up translation of thinBasic scripts
Setup your script for translation
Build translation file without thinAir integration
thinAir integration (with bundling version)
thinAir integration (without bundling version)
Translation-file building
Limitations
- Copy the file I18N_helper.tbasicu to the same path as your main script
- From I18N_helper.tbasicu copy the part of code that is at the top and paste it in your main script
- Uncomment it and make the adjustments you need (language selection).
- Anywhere you need a String translation, enclose it with i18nh("your string to translate") or i18nh("your string to translate","any comment to the translator")
Or see thinAir integration below.
- Open your main script in thinAir
- Right click on the script TAB name
- From the context menu, copy file name to clipboard
- thinAir menu : Script\Command Line ...
- Right click in the input bar and paste the path, then click OK
- Run I18N.tbasic
- In your main script folder, edit your xml file (I use Notepad++) to complete it with translations.
see thinternational Sample folder fo example.
Or see thinAir integration without bundling below.
- Whithin thinAir build I18N.tbasic to I18N.exe
- Create folder %thinBasic_Installation_Folder%\thinAir\Tools\thinternational
- Move I18N.exe to _%thinBasic_Installation_Folder%\thinAir\Tools\thinternational_
- Edit %thinBasic_Installation_Folder%\thinAir\Tools\thinAir_Tools.ini and append the following section :
[thinI18N] Menu=thinternational CommandLine=%thinAirinstallpath%\Tools\thinternational\I18N.exe %sourcecodefullpathnameext% SaveScriptBefore=true
- Restart thinAir
- Create folder %thinBasic_Installation_Folder%\thinAir\Tools\thinternational
- Move I18N.tbasic to _%thinBasic_Installation_Folder%\thinAir\Tools\thinternational_
- Edit %thinBasic_Installation_Folder%\thinAir\Tools\thinAir_Tools.ini and append the following section :
[thinI18N] Menu=thinternational CommandLine=%thinbasicinstallpath%\thinbasicc.exe "%thinAirinstallpath%\Tools\thinternational\i18N.tbasic " %sourcecodefullpathnameext% SaveScriptBefore=true
- Restart thinAir
- Open your main script in thinAir, stay on this tab.
- thinAir menu : Tools\User Tools\thinternational
- In your main script folder, edit your xml file (I use Notepad++) to complete it with translations.
Due to an actual limitation from TB's gettext() that trims translated strings, beginning and ending spaces characters, if any, have to be hardcoded.
Due to another limitation from TB's gettext(), all source languages as well as later versions (mostly symbols) of unicode characters are not supported in the script's body. Tested working language are english, french, italian. One workaround is to declare the source language (the one in the script) with a fake name (example: $DEV_LOCAL = "Source_en-GB" ) and use the translation file to store any convenient character even for i18n.Setlocale("en-GB") .