Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been using for a while in my Ubuntu-Touch projects. I know what this function is about but I don't know how to add a translation to my project.

Where do I have to place my translation file? With what name? How must its content be written? How should I connect it with my app? How do I test it with qmlscene ?

share|improve this question

Take a look at TouchWriter code and especially its README, where all needed commands are given.

Quick summary

  • You need to bind the text domain before using gettext. In C++ you can do it like this:

    bindtextdomain("domainname", "somedir");

    In Qml you can probably do something like this:

    i18n.bindtextdomain("domainname", "somedir");
    i18n.domain = "domainname";

    Be sure to do that before is used.

  • To generate .pot template and source .po files, use these commands:

    xgettext -C --qt --keyword=tr -p somedir -o messages.pot
    msginit -i somedir/messages.pot -o somedir/somelanguage.po

    (replace somedir with the directory your domain is bound to, and somelanguage with the language you want to translate to).

  • To generate .mo files from source .po files, use msgfmt po-file -o mo-file command.

  • Compiled .mo files should be placed inside a directory you bound the text domain to, more specifically in


    (replace somedir, somelanguage and domainname with your values).

share|improve this answer
Ok i downloaded the source and checked some of the commands. Do you also know how do I test the translations via qmlscene ? – George Sofianos Sep 24 '13 at 10:31
@GeorgeSofianos I've updated the answer with instructions of how to bind text domains and where you should place your files. Note that in my case I did that in C++ code, but doing that in QML should work as well. – Dmitry Shachnev Sep 24 '13 at 15:33
(You can easily create .pot and .mo files directly in Qt Creator – Alexandre Hitchcox Sep 25 '13 at 17:01

The best answer seems to be in the doc.

It seems to be a function that translates the word passed to the user's language.

share|improve this answer
Please read my question more carefully , especially the part "I know what this function is about" and what I ask after it. – George Sofianos Sep 24 '13 at 5:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.