GUI Translation

Revision as of 21:06, 12 July 2007 by Mheiland (talk | contribs) (added some information about translation)

This page describes the steps required to translate the AJAX GUI into a new language.

Preparation

Before translating anything, it is recommended that the server and the GUI are installed as described in the installation tutorial. If translations are tested somewhere else, the server is not strictly necessary. In this case, only sections II.1, II.2, II.7, III.1, the Saxon library from section III.2, and section IV.4 of the tutorial are relevant.

The translations use portable object (PO) files from GNU Gettext as file format. There are several tools available to edit the translations:

At least one of these will be required by the translator.

Generating a translation template

Translations are usually performed by filling out a translation template. This template (a file with the extension .pot) is generated by executing the pot task in Ant:

ant -Dlib.dir=/opt/open-xchange/lib/ pot

The -D switch should specify the same path as in section IV.4 of the installation tutorial. This will produce a file called ox.pot in the i18n directory of the GUI source. This file contains all untranslated text strings found in the source code. The corresponding entries can be either entered manually or merged automatically with an existing translation created for an older version of the GUI. In the latter case, only new and changed strings need to be updated manually. The dedicated tools are a great help for this task.

Installing

After a POT file is translated or merged, it should be saved as ox.LANG.po, where LANG is the language code like e. g. de_DE or en_US. Any directory below the i18n directory of the GUI source will work, but to avoid conflicts with other translations, each translation should be saved as i18n/LANG/po/ox.LANG.po.

For example:

/usr/src/open-xchange-gui/i18n/xx_XX/po/ox.xx_XX.po

Now we have to tell the GUI and and the build script where to find our new translation and how to name it in the user configuration. To make this more transparent, i will use xx_XX as my new language. Make sure that you have to do all this modifications in the source files, not at the already compiled scripts. This has to be done at the following places:

/usr/src/open-xchange-gui/build.xml
/usr/src/open-xchange-gui/js/check.js
/usr/src/open-xchange-gui/js/global.js
/usr/src/open-xchange-gui/js/timezone.js

The following code-snippets only have to be enhanced by some characters, just search for the code and add what you need:

/usr/src/open-xchange-gui/build.xml

<copy todir="${langdir}" encoding="UTF-8">
  <fileset dir="${basedir}">
    <include name="${builddir}/ox.de_DE.po"/>
    <include name="i18n/en_US/po/ox.en_US.po"/>
    <include name="i18n/fr_FR/po/ox.fr_FR.po"/>
    <include name="i18n/xx_XX/po/ox.xx_XX.po"/>
  </fileset>

/usr/src/open-xchange-gui/js/check.js

if (match) {
  if (match[2]) {
    lang = match[1].toLowerCase() + "_" + match[3].toUpperCase();
    if (!{"de_DE": true, "en_US": true, "fr_FR": true, "xx_XX": true}[lang])
      lang = {de: "de", en: "en", fr: "fr", xx: "xx"}[match[1].toLowerCase()] || "de";
  } else
       lang = {de: "de", en: "en", fr: "fr", xx: "xx"}[match[1].toLowerCase()] || "de";
}

/usr/src/open-xchange-gui/js/global.js

same changes as js/check.js

/usr/src/open-xchange-gui/js/timezone.js

var languages     = new Array(
  "English"
 ,"German"
 ,"French"
 ,"XX-Language");

var language_code = new Array("en_US", "de_DE", "fr_FR", "xx_XX");

After that, the new translation must be transformed to JavaScript and copied to its final destination on the web server. this is done by starting Ant again, as described in section IV.4 of the installation tutorial:

ant -Dlib.dir=/opt/open-xchange/lib/ deploy

Testing

TODO: find a way to actually select new languages in the GUI.

Until then, manually finding and replacing the current language setting of a user in the database should work until that user tries to change the language.