Language Support
From Aikiframework wiki
|
This feature is under active development: https://blueprints.launchpad.net/aikiframework/+spec/translation |
|
Aiki supports multiple languages. We are adding a simple widget that will allow for translation, but in the meantime, #Developers get to have all the fun.
Developers
Aiki has two built in support for translation. One is based in L10N and other is similar to unix gettext system. Both system using language detection by url, site configuration of languages, and they can work together.
Language defined for each site
For output, each website can have a default language and a list of allowed languages. For example, you can define 'es' as default language, and allowed 'en', 'fr'.
The user language, is obtained from URL, using first part of path:
- www.mysite.org/fr
- www.mysite.org/en/news
- www.mysite.org/es/admin
Aiki try to determine if first part of path is a allowed language (including default). If can, this language will be used for generate output. If not, default language is used. In our previous example:
- www.mysite.org/fr -> french
- www.mysite.org/en/news english
- www.mysite.org/admin (spanish)
Table aiki_site, stores allowed and default language for a site.
table: aiki_languages
Aiki stores in this table some information of language: english name, iso-639-2 code, and direction of language. This information is used to generate dir tag in html tag. If you added a language in Aiki, please add the correspond records in this table.
L10
Aiki has built in support for L10N (Internationalization). To translate a term, you must convert into symbolic representation using only ASCII chars and _ (spaces are not allowed), and surrounded it with __
example code in widget: __hello_friend__ in code (only for aiki developers) pagination .= "a href..__NEXT__...";
Aiki make translation on all __terms__ searching them in table aiki_dictionary, and returning the column lang_ISO_CODE_OF_LANGUAGE. By default aiki_dictionary have columns for Arabic (lang_ar), Chinese (lang_ch), English (lang_en) and German (lang_ge).
You can add your own language column using ISO-639 with two digit if you want add other language.
Gettext
Aiki framework support a system similar to gettext in implementation, and based in url to define language. We assume:
- aiki core is developed in english.
- aiki output can be translate to any language. A site can define a unique default language.
- aiki widget can be developed in any unique language (recommended).
choose one..or work with both
For translating you sites you can use L10 or gettext or both. Every system have advantages (+) and disadvantages (-)
L10 (-) every term must be translated. (-) when you add a literal, you must add in the table, instead you have only one language. (+) large text allowed. (+) you can correct literals without touching code or widget.
Gettext (+) don't need translation for default language. (+) make you site..and one day you will translate it. (-) only string (not long text) (-) correct terms required touch code, and changes all translations.
Adding a language to my site
If you have a site with only one language, for example "en", and you want add a second language you must do:
- change site configuration. Define default language and widget language like you unique language ("en" in the example) and add in allowed language the new language. Important: You don't lost track-back, link or references, because www.mysite.org/something (old link) and www.mysite.org/en/something are equal.
- edit dictionaries.
- change widget. In widget, if you have used [root] for internal links, to must change them to [route].
See Related Pages
- Aiki languages is for developers to add language support.
- Aiki Documentation

