Shark
30th June 2017, 14:53
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 <"));
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
And in main.cpp
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
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!
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 <"));
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
And in main.cpp
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
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!