appJar offers a simple method for supporting multiple languages.
A config file is created, for each supported language, containing a translation for each widget.

File Format

The config file's name should be the language it represents, with an extension of .ini.
Within that file will be a [SECTION] for each widget type, followed by a list of widget IDs and their translation, separated by colons.

For example, a file called ENGLISH.ini might contain:

l1: some text
l2: some more text

b1: button a
b2: button b

e1: --default text--

l1: New link title

If no translation is found, the widget's initial value will be used as a default.

NB. The filename should be in all uppercase, of type .ini

Coding It

from appJar import gui
app=gui("Language Demo")

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)


The starting language can be set in the call to .go() or provided as a command line argument.

To change the language, call .changeLanguage(language)

Command Line Arguments

It is possible to set the starting language as a command line argument:

    python3 -l ENGLISH

This will override any language set in the call to .go(), and removes the need to set one at all.

Advertisement why?

Widget Support

NB. changing the text of a widget through setXXX() method's will work, but will not be remembered if the language is changed.

default-flag.jpg: mexican-flag.jpg

default-anthem.wav: mexican-anthem.wav
default-speech.wav: mexaican-speech.wav
default-welcome.wav: mexican-welcome.wav
appJar: Main GUI Title
splash: New Splash Text
statusbar: DATA
sub1: SubWindow 1 Title
sub2: SubWindow 2 Title
Food-rb1: baguettes
Food-rb2: fromage
Food-rb3: vin

props-prop1: Extra Cheese
props-prop2: Sweetcorn
props-prop3: Pineapple

mainFrame-Tab1: Information
mainFrame-Tab2: Extras
mainFrame-Tab3: Details
financesGrid-actionHeading: Update Row
financesGrid-actionButton: Update
financesGrid-addButton: Add

Address Book-title: AddressBuch
Address Book-prevButton: Vorhergehend
Address Book-nextButton: Danach

    Confirm Exit
    Press OK to confirm exit.
    Confirm Save
    Press OK to confirm you want to save the file.
def saveFile(btn):
    # SAVE-POPUP is a translation key, so the two parameters should be replaced
    if app.okBox("SAVE-POPUP", "Confirm you want to save."):

def quit(btn):
    # SAVE-POPUP is a translation key, so the two parameters should be replaced
    if app.okBox("EXIT-POPUP", "Confirm you want to exit."):
button1: New Button Name
button2: Another New Button Name
button3: One More New Button Name
OPEN: This will be ignored because it has an image...
l1: New tooltip text.
l2: Another new tooltip text

e1: Some more tooltip text

External Translations

It's also possible to store additional translations to use on the fly. These are extra pieces of text you might want to translate during the running of the application, which aren't linked directly to a widget.

VALUE-1: This is some translated text.
VALUE-2: This is some more translated text.
VALUE-3: This is the last piece of translated text.

These can then be accessed by using appJar's .translate(key, default=None) function.

# this function will print out some translated text
def showMessage():

The default value will be returned if no translation is found.

Widgets Not Supported

Platform Support

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