[ Resolved ] QTranslator and UTF-8 combo give me trouble
(Using Qt 4.7.4 on Mac)
My *.TS files are generated and are UTF-8 using a perl script I wrote. Long story with legacy dependency. We have 13 languages we have to support including some exotic ones. Generating *.QM files out of them seems to work well. You can load the *.QM file into Qt Linguist and everything looks healthy.
Due to legacy reasons, my system langauge is “Enums”. That is, I do something like this:
- QString label = tr("APP_STRINGS_MYLABEL_TEXT"); // this translates to 13 langauges...
so, an excerpt from the english .TS file for instance reads:
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE TS>
- <TS version="2.0" language="en">
- <translation>My Label Text In English</translation>
My project file has the following:
- CODECFORTR = UTF-8
My main method has test code that looks like this:
- QTranslator translator;
- bool empty = translator.isEmpty(); // Returns TRUE
- bool loaded = translator.load("myApp_en","/Users/user/Dev/myApp/translation");
- empty = translator.isEmpty(); // returns FALSE
- // install the translator.
- // Here comes my problem...
- QString test = MyApp->trUtf8("APP_STRINGS_MYLABEL_TEXT"); // returns "APP_STRINGS_MYLABEL_TEXT"
- QString test2 = MyApp->tr("APP_STRINGS_MYLABEL_TEXT"); // returns "APP_STRINGS_MYLABEL_TEXT"
As you can see, all my strings are being translated back to their original values. No real translation takes place. If you have any idea why thins might be happening, i’d appreciate the assistance. I am at a loss right now.