-
Notifications
You must be signed in to change notification settings - Fork 22
Gettext for vle 1.1
Gettext is a program intended for the management of languages in computer applications. Program coming from the GNU project, It is very used in freeware, command line applications, graphical user interfaces and web sites. Gettext is a set of programs and a "C" API.
For more information: see the documentation of Gettext and the wikipedia page.
The functions of the gettext "C" API are available by including the file i18n.hpp in the directory
vle/utils/i18n.hpp. In the VLE source code source, the sentences to translate have to be written in English and be put in a call to the gettext() function :
#include <vle/utils/i18n.hpp>
#include <iostream>
using vle::fmt;
// simple translation (from french)
std::cout << _("phrase à traduire\n");
// translation with string formatting thanks to boost::format (from french)
std::cout << fmt(_("phrase à traduire avec paramètres : %1%\n")) % param);
// translation of a long formatted string (from french)
std::cout << fmt(
_("Very very very very very very very very very very very "
"" very very very very very very very very very very very"
"long sentence : %1%\n") % param);
// plurals handling, using a parameter (unsigned long int)
std::cout << ngettext("model", "models", nb);
// plurals handling, using a predefined string
std::cout << fmt(ngettext("%1% model", "%1% models", nb)) % nb;
Creation of the catalog from all the C++ files and Glade :
cd git/vle
find . -name "*pp" > /tmp/FILES
find . -name "*glade" >> /tmp/FILES
xgettext --language=c++ --boost -k_ -j -f /tmp/FILES -o i18n/vle-1-1.pot
Creation of a french translation file of translation:
cd git/vle/i18n
msginit -l fr -o fr.po -i vle-1-1.pot
Compilation of a catalog (build by the Gettext script of CMake):
cd git/vle/i18n
msgfmt -c -v -o fr.mo fr.po
Update of a translation file with one new release of the catalog file:
cd git/vle/i18n
msgmerge --update fr.po vle-1-1.pot