In this section, we will elaborate class Item in an app named Sessions, as introduced in the previous section. The objective is to illustrate more features about Appy classes.
Preamble · Internationalization (i18n)
As a preamble, because internationalized user interfaces is a built-in Appy feature, we will configure our app to support 2 languages: English and French.
By default, only English is supported. Adding more languages can be done via the main configuration file, Sessions/__init__.py, by adding the ISO-639 2-letters language code, as shown in line 11:
01 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
02 class Config(appy.Config):
03 server = server.Config()
04 security = guard.Config()
05 backup = backup.Config()
06 jobs = scheduler.Config()
07 database = database.Config()
08 log = log.Config()
09 model = model.Config()
10 ui = ui.Config()
11 ui.languages.append('fr')
12 deploy = deploy.Config()
13 peers = peer.Config()
14 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Describing the Config class in detail will not be done here. It is not recommended to remove English (en) from ui.languages, as it serves as default and/or fallback language at various places in the framework.
Call the Sessions/make.py script for the new language to be taken into account.
cd <your_apps_folder>/Sessions
./make
After executing this, you will see 2 more files in Sessions/tr: Custom-fr.po and Sessions-fr.po.
ls tr
Custom-en.po Custom-fr.po Custom.pot Sessions-en.po Sessions-fr.po Sessions.pot
-