appJar offers a simple method for supporting multiple languages.
A config file needs to be created, for each language, with translations for each widget:
>>> ENGLISH.ini --- [LABEL] l1: some text l2: some more text [BUTTON] b1: button a b2: button b [LINK] l1: New link title
When widgets are added, their ID will be used to look up a translation.
If no translation is found, the widget's initial value will be used as a default.
The filename should be in all uppercase, of type
from appJar import gui app=gui("Languages") app.addLabel("l1", "default text") app.addLabel("l2", "default text") app.addLabel("l3", "default text") # as long as the language file has the same name as the button # the button can call .changeLanguage directly app.addButtons(["English", "Francais", "한글"], app.changeLanguage) app.go("english")
The starting language must be set in the call to
To change the language, call
These will look for a file called
Not all widget's are supported, and some require a bit more effort to get them to work properly.
Note, changing the text of a widget through
setXXX() method's will work, but will not be remembered if the language is changed.
Any widgets created with an auto-label can be changed under the
The label id, followed by the text to put in it.
Any widgets added with labels
.addLabelEntry()are also changed here.
Radio-buttons are a little tricky. The key has two parts: the group & item
If you used:
.addRadioButton("Food", "f1")the entry in the
.inifile would be:
The text provided here wil be used for the default value, if one is being used.
These widgets have no text to change.
Each value should be on a new line
Doesn't work for SpinBoxes, when generated from a range.
[LISTBOX] fruits: apples pears grapes bananas
The following are currently in development:
It will be possible to request translations for non appJar data.
Note, your platform might not support the characters you want to display.
In which case, you'll need to install the relevant font.
For example, to get Korean characters to show on raspberry Pi, try:
sudo apt-get install fonts-nanum
If you're after other languages, you can try:
apt-cache search chinese and then install a likely looking font...