qilinguist can be used with qt or gettext.
In the following tutorial, you will learn how to configure qilinguist, and how to use it to build and install translation files.
Table of contents
<worktree>
|__ hello
|__ qiproject.xml
|__ po
| |__ POTFILES.in
|__ hello.cpp
<!-- qiproject.xml -->
<project version="3">
<qilinguist name="hello" linguas="en_US fr_FR" tr="gettext" />
</project>
# po/POTFILES.in
hello.cpp
// hello.cpp
#include <libintl.h>
#define _(string) gettext(string)
setlocale(LC_ALL, "");
bindtextdomain("hello", ...);
textdomain("hello");
std::cout << _("Hello, world");
Run qilinguist update
This will create or update the .po files in the po directory, one for each language defined in the linguas attribute of the qilinguist tag in the qiproject.xml
Run qilinguist release.
This will create all the .mo files from the .po files.
<worktree>
|__ hello
|__ qiproject.xml
|__ po
| |__ POTFILES.in
|__ hello.cpp
<!-- qiproject.xml -->
<project version="3">
<qilinguist name="hello" linguas="en_US fr_FR" tr="linguist" />
</project>
# po/POTFILES.in
hello.cpp
// hello.cpp
#include <QApplication>
#include <QTranslator>
QApplication app;
QTranslator translator;
translator.load(..., ...);
app.installTranslator(&translator);
QString hello = QApplication::tr("Hello world!");
Run qilinguist update
This will create or update the .ts files in the po directory, one for each language defined in the linguas attribute of the qilinguist tag in the qiproject.xml
Run qilinguist release.
This will create all the .qm files from the .ts files.