Hi,
I want to have all the translated strings in one place in my source code, so I've created a Strings class that extends QObject that consists of static QString objects.
The header file contains declarations like:
const static QString PENDING;
To copy to clipboard, switch view to plain text mode
and then a .cpp file contains
const QString Strings
::PENDING(tr
("Pending"));
const QString Strings::PENDING(tr("Pending"));
To copy to clipboard, switch view to plain text mode
I can run lupdate on the .cpp file, open the resulting .ts file in linguist and see that I need to translate "Pending". I do that, save everything, and run lrelease.
Then in the main method of my app, before creating widgets I run:
QString file ("/usr/local/swdevel/share/dbaker/lib/instr_fr");
bool loaded = translator->load(file);
TRACE("Loaded: %s\n", loaded ? "true" : "false");
app.installTranslator(translator);
QString file ("/usr/local/swdevel/share/dbaker/lib/instr_fr");
bool loaded = translator->load(file);
TRACE("Loaded: %s\n", loaded ? "true" : "false");
app.installTranslator(translator);
To copy to clipboard, switch view to plain text mode
but when I try to display or just print out the value of the variable, I only get the English.
Is there some problem with using tr in static members of a class?
Thanks in advance.
Derek
Bookmarks