PDA

View Full Version : QT translate with ID



nmantelier
6th January 2017, 13:05
Hello,

I need to translate a program via QT translate.
And I am looking a way to use ID instead of source message. But to keep source message as default value if ID was not find in translator.

Something like:
tr("ID_145587","This is default string")
If ID_145587 is find by translator we use the translated string else we use "This is default string".

I find a way to do this partialy
//% "This is default string"
QString translated = qtTrId("ID_GUI_1564");
That allow to use "This is default string" if string as not been translate but display "ID_GUI_1564" if no qm loaded.
And i do not find a way to work with string with param like tr("Value string is %1").arg(QString(value))

There is any way to do that i need ?

anda_skoa
6th January 2017, 13:50
Not sure I understand, qtTrId() returns a QString, "arg" is a method of that class.

Cheers,
_

nmantelier
6th January 2017, 14:47
You have right i probably make a mistake on first try cause i was an error on qm Loading.

I try the same with only this string on ts (I was using a ts with mix ID and classic tr) and that works.