-
Notifications
You must be signed in to change notification settings - Fork 95
Translation
How to translate Skosmos to a new language, or to edit existing translations
Translations are implemented using gettext and managed by editing po
files. In addition, the translations and locales to use in a particular installation are defined by the LANGUAGES setting in config.inc
; see Configuration for details.
Translations are best edited using Poedit.
- Install Poedit in Debian/Ubuntu:
apt-get install poedit
- Install Twig Gettext Extractor to let Poedit parse translatable strings from Twig templates.
- Install it using Composer by running this command in the root of the ONKI Light code repository:
php composer.phar install
- Install it using Composer by running this command in the root of the ONKI Light code repository:
- Set up Poedit to use the extractor following the installation instructions on the Twig Gettext Extractor home page, except use
tools/twig-gettext-extractor
as the path because we need to use our customized version of this script due to our custom Twig filters.
In Poedit, you can then update the catalog (i.e. extract all translatable strings), edit the translations for each language, and save the results.
If the word you want to translate can't be found in the .po files you will need to add {% trans %}
and {% endtrans %}
tags to the object to be translated in the twig templates. After that you can add the word to the .po file with its translation.
Some strings to be translated do not naturally appear in the Twig templates or PHP code, e.g. SKOS qnames such as skos:broader
. Such strings are listed in the Twig template extra_msgids.twig which is not actually used by Skosmos for rendering, only for feeding the extra messages to xgettext/Poedit.
The translations are located in .po files under resources/translations/
For example if you want to make changes to the Finnish translation of Skosmos the file you will need to update is skosmos_fi.po
.
After you have made the desired changes to the .po file you will need to run the translation script trans_script
located in the same folder eg. in linux sh trans_script
. The script creates the machine readable .mo files and moves them to the corresponding folders. Finally it restarts the local apache server so you can see your changes immediately without any cached results.
To translate to a new language, you need to:
* create a .po file for that language under resource/translation/
using e.g. Poedit
* create a directory resource/translation/lang/LC_MESSAGES/
(where lang
is the language code for your new language)
* update trans_script
with code that compiles the .po file to a .mo file and puts it to the above directory
* compile the language files with trans_script
* add the new language to config.inc
so it gets used