[Interest] Translation support totally broken

Philipp Kursawe phil.kursawe at gmail.com
Wed Dec 18 16:05:32 CET 2013

I don't know about other multi-plugin projects realized with Qt but I am
having massive troubles to facilitate the Qt translation system correctly.

First flaw I see is the whole "Embedd the default text in the source code".
Translations should always be external and id based. The Qt tools cannot
even handle the (default) way in Qt to embed the base language in the
source code. When you change the wording or move the text definition in the
cpp file the ts file will contain one new entry and an obsolete entry (most
of the time).

But when you want to use id based translations you lose the context. Also
you cannot use id based translation in .ui files at the moment.
So imagine I have 2 plugins, both define a string with the id "about". I
create on translator for each plugin I load and add them the the global
translator table using qApp.installTranslator.

Now, the "about" text is different in each plugin. During runtime of course
calling qtTrId("about") will always return the translated text of the first
loaded plugin. To solve the problem I tought, I could prefix the ids with
something unique to the plugin like this "plugin1/about" and
That works. But what if I want to display the about text of plugin1 in
plugin2? I would write qtTrId("plugin1/about") in my plugin2 cpp file and
lsupdate will then create a new entry in plugin2.ts file named

That is not such uncommon use-case where you want to bundle common strings
in one place and use them from different plugins. How can this situation be

I am down to using the plain .ts files renamed as "lang" and read them
directly using my own small XML XPath function. It also saves one step of
lsrelease (which is not capable of mixing .ui and cpp translations anyway).

I still sometimes feel that with Qt you go a long way very fast but when
you hit a wall then you hit it hard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131218/1a1cd2bf/attachment.html>

More information about the Interest mailing list