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 (http://en.wikipedia.org/wiki/Gettext) 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 (http://www.poedit.net/) 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
You have to configure your poEdit to use the following (catalog-)settings:
Please make shure to chose the appropriate plural forms.
And in the preferences/parser setup:
Including Translations in sourcecode
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(); translation.textdomain('Tasks');
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 http://framework.zend.com/manual/en/zend.locale.functions.html#zend.locale.getdata) you can use this function (in this example, the format string for a medium length date is fetched):
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.
$translate = Tinebase_Translation::getTranslation('Crm'); $translatedString = $translate->_('Probability');
For more information on the PHP gettext implementation and Zend_Translate visit http://php.net/gettext and http://framework.zend.com/manual/en/zend.translate.html.