By default Sahana Eden displays all information in US English. However, the system is fully internationalized, which means that all text elements of the user interface can be displayed in any language, including right-to-left languages.
The process of "localizing" Sahana Eden (adapting it to specific language and locale) involves translating the text elements of the user interface into whatever language is needed.
Many translations are already available for Sahana Eden, although they may not be complete or not up-to-date. These include:
- Chinese (Simplified)
- Chinese (Traditional)
- English (UK)
- Portuguese (Brazil)
- Portuguese (Portugal)
Updating an Existing Translation
If you need to update an existing translation, either because it is incomplete or to add customized strings specific to your installation, then you need to update a text file in the languages folder (e.g. languages/de.py for the German translation). This file contains a Python dictionary to map the original US English strings to their translated counterparts.
There are 2 approaches that you can take to generate an empty language file for translation:
- If you have just a small number of modules that you wish to translate quickly then you can remove all untranslated strings from an existing language file. Then navigate through these modules - this will add any untranslated strings that the system encounters to the language file (assuming the relevant file permissions allow this).
- If you wish to translate the entire application as part of a Preparedness project then you can update all the language files in languages by doing the following:
cd web2py python web2py.py -S eden -R applications/eden/static/scripts/tools/languages.py
There are 3 approaches you can take to do the translations:
Note: Inform all translators to not translate the variables within strings (e.g. %(name)s), but just move around the surrounding text to ensure that the word order makes sense.
- If you have a small number of strings to translate then it is possible to do this using the Web2Py Admin Interface (this assumes that you have a local branch on your machine to work on):
- If you want to send these strings to be translated by a professional translation company, then they will typically expect the strings in spreadsheet format. You can create a CSV of strings using the Translate Toolkit:
- If you want to use a community of translators then you can use Pootle (see below).
web2py2po -i language.py -o language.po po2csv -i language.po -o language.csv
Tip: Excel has a nasty habit of corrupting strings with quotation marks or other special characters, so avoid this if possible & be prepared to clean-up if not.
Adding a New Translation
This can be done via the Web2Py admin interface:
Create a new file using the ISO 639-1 Code of the Language plus ".py" as the filename. If it is a national variation of a language, eg. New Zealand English, add a suffix to the language code: "en_nz.py".
The same process then applies as for updating an existing language.
Using Pootle to Manage Translations
Pootle is a web-based tool to manage translations by a group of translators which includes the ability to have alternate suggestions reviewed before being selected.
There is a Sahana instance at http://pootle.sahanafoundation.org which is available for you to manage the translation for your language.
To use Pootle you need to convert the .py version of your translation to/from the PO format, which can be done using web2py2po from the Translate Toolkit.