Internationalisation


appJar offers a simple method for supporting multiple languages.

File Format

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 .ini

Implementation

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 .go(language)
To change the language, call .changeLanguage(language)

These will look for a file called LANGUAGE.ini

Widget Support

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.

[LISTBOX]
fruits:
    apples
    pears
    grapes
    bananas

Platform Support

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...