Internationalization and Localization

From VLE

Jump to: navigation, search

In computing, internationalization and localization (also spelled internationalisation and localisation, i18n and l10n) are means of adapting computer software to different languages, regional differences and technical requirements of a target market. Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by adding locale-specific components and translating text.


Gettext

To translate the software in VLE an in VFL, we use the Gettext program from the GNU Project. For more information see:

Developers

We profite Gettext functions in file vle/utils/i18n.hpp:

 namespace vle {
   using boost::format fmt;
 }
 
 /* Internationalization Dependances */
 #include <libintl.h>
 #include <locale.h>
 #define _(x) gettext(x)

Now, in the source code of VLE:

 #include <vle/utils/i18n.hpp>
 #include <iostream>
 using vle::fmt;
 
 // traduction simple
 std::cout << _("phrase à traduire\n");
 
 // traduction avec formatage de la chaîne à l'aide de boost::format
 std::cout << fmt(_("phrase à traduire avec paramètres : %1%\n")) % param);
 
 // traduction d'une grande chaîne avec formatage
 std::cout << fmt(
	_("Phrase très très très très très très très très très très "
          "très très très très très très très très très très très "
          "longue : %1%\n") % param);
 
 // gestion des pluriels, utilisation d'un paramêtre (unsigned long int)
 std::cout << ngettext("model", "models", nb);
 
 // gestion des pluriels dans une chaîne construite
 std::cout << fmt(ngettext("%1% model", "%1% models", nb)) % nb;

Translators

Build a catalog file from C, C++ and Glade files:

cd git/vle
find . -name "*.c" > /tmp/FILES
find . -name "*.h" >> /tmp/FILES
find . -name "*.cpp" >> /tmp/FILES
find . -name "*.hpp" >> /tmp/FILES
find . -name "*glade" >> /tmp/FILES
xgettext --language=c++ --boost -k_ -j -f /tmp/FILES -o i18n/vle-1-0.pot

Build a translation file:

cd git/vle/i18n
msginit -l fr -o fr.po -i vle-1-0.pot

Build a catalog file (build by the Gettext CMake's script):

cd git/vle/i18n
msgfmt -c -v -o fr.mo fr.po

Update the traduction file with the new release of the calalog:

cd git/vle/i18n
msgmerge --update fr.po vle-1-0.pot
This page was last modified on 18 January 2011, at 14:02. This page has been accessed 214 times.