Dear programmers,
in my Gui application (Qt version 4.8) I often use tr() to tanslate strings. It does work well with all string literals except those which contain utf-8 characters.
For example, such a line is
absChiSqrCheckBox
= new QCheckBox(tr
("\317\207\302\262 change <"));
absChiSqrCheckBox = new QCheckBox(tr("\317\207\302\262 change <"));
To copy to clipboard, switch view to plain text mode
So here we have the two utf-8 characters "χ²" (chi^2) encoded as octal C-characters.
In my qmake project file I have
CODECFORTR = UTF-8
CODECFORTR = UTF-8
To copy to clipboard, switch view to plain text mode
And in main.cpp
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
To copy to clipboard, switch view to plain text mode
I run lupdate, then the linguist and release the qm files.
So it seems I did exactly as is described in the Qt 4.8 documentation. I also tried trUtf8() instead of tr(), but this works neither. A string like the above is simply not translated.
Many thanks for answers!
Bookmarks