Developers/Concepts/Translation Howto

From Tine 2.0 - Wiki

< Developers

Tine 2.0 Translations Howto


This HowTo gives a short description how new translations can be added to a Tine application (frontend and backend) and how existing translations can be altered.


We are using the GNU gettext library ( for the internationalization of Tine 2.0.

Every Application should have a 'translations' directory where the .po and .mo files for the supported languages are stored.

Translations with poEdit

There is a nice tool called poEdit ( to create the .po files and add/change the translations.

Here is a short introduction how to use poEdit in screenshots.

In this example you can see the german Addressbook translation .po file.

poEdit main translation screen

Poedit screen.png

poEdit settings

For the parsing of javascript files, it is needed to add *.js files to one of the parsers in the preferences (we used the python parser) or add a special javascript parser.

You have to configure your poEdit to use the following (catalog-)settings:

Please make shure to chose the appropriate plural forms.

Poedit Settings.png

Poedit Settings paths.png

Poedit SettingsKeywords.png

And in the preferences/parser setup:

Poedit Parser setup.png

Including Translations in sourcecode


Since Javascript has no native gettext support, we have to parse the .po files and create javascript objects for the different languages. The locale is set by the server using the Zend Frameworks Zend_Locale class. The release.php script is used to build the javascript translation files which are stored in the Tinebase/js/Locale/build directory. When the application is loaded, the matching translation and locale js files are included in the HTML head:

    <script type="text/javascript" language="javascript" src="ExtJS/build/locale/ext-lang-de-min.js?1209478552"></script>
    <script type="text/javascript" language="javascript" src="Tinebase/js/Locale/static/generic-de_DE.js?1211366337"></script>
    <script type="text/javascript" language="javascript" src="Tinebase/js/Locale/build/de.js?1211383646"></script>

In the ExtJS Frontend we have a dedicated Object for the translation of strings.

This is how you get it:

        var translation = new Locale.Gettext();

The function call textdomain('Tasks') gets the the translations for the 'Tasks' application.

To translate a string you just have to call the "_()" function of the translation object:

        var translatedString = translation._('Tasks')

If it is needed to print the correct plural forms, you can do it this way;

NOTE: you have to use the ngettext function and not the n_ shortcut, as most versions of poedit can't cope with the n_ version.

        var translatedString = sprintf(translation.ngettext('Link', 'Links [%d]', numlinks), numlinks)

To access the Zend Translation Lists (see you can use this function (in this example, the format string for a medium length date is fetched):

        Locale.getTranslationData('Date', 'medium')


In the PHP backend we use the translation and locale classes of the Zend Framework (Zend_Locale and Zend_Translate). We also added a wrapper class called Tinebase_Translation to get the matching translations for our applications. The browser locale is stored in the Zend_Registry.

Code example:

        $translate = Tinebase_Translation::getTranslation('Crm');    
        $translatedString = $translate->_('Probability');

For more information on the PHP gettext implementation and Zend_Translate visit and