Skip to content

Translation

Koen Teuwen edited this page Sep 2, 2021 · 3 revisions

The website is translated using gettext. By default, all strings are written in English.

Code

In the code, string should be translated with the translator, which can be obtained with the ServiceManager. Then, strings should be translated as follows:

<?php
// obtain the translator
$translator = $sm->get('translator');
echo $translator->translate('Some text');

Views

Most translation actually happens in views. Thus, there is a translate view helper to help translation in views along. In views, you don't have to worry about translator setup, you can simply use $this->translate() to translate strings.

Translate helper

In the main directory of the project, there is a translate-helper shell script. If the script is executed, all strings which are translated by the translator, will be gathered in module/Application/language/gewisweb.pot. From here, the language files (which are located in module/Application/language/) are automatically updated by running msgmerge lang.po gewisweb.pot. (done by shell script as well). This updates the existing language file with newly added strings.

Translation

The translation files en.po and nl.po should be translated with an editor like POEdit. When saved, these will be converted to the binary *.mo files used by the translator.