PDA

View Full Version : Translate my app (dynamic)



liran ritkop
30th March 2011, 15:30
I have some troubles...
I declare an array of string in a global object like that:

GeneralStruct::GeneralStruct(QWidget *parent):QWidget(parent){
greeting_strings[0] = QT_TRANSLATE_NOOP("Global, "France");
greeting_strings[1] = QT_TRANSLATE_NOOP("Global, "Energy");
greeting_strings[2] = QT_TRANSLATE_NOOP("Global, "Caps");
greeting_strings[3] = QT_TRANSLATE_NOOP("Global, "Switch");
};
and than i place in another object the translated texts in that way:

for (i=0; i<Number_Of_Boxes; i++)
boxes[i].Text = QCoreApplication::translate("Global", generalStructObject->greeting_strings[i]);

It doesn't work..
I don't understand why...?
How should i use the thing with context? i have to do it cause i use different objects with the same tr() translations..

ChrisW67
30th March 2011, 23:01
Apart from the obvious typing errors in your first code snippet, what about it "doesn't work"? Doesn't compile? Doesn't output in Swahili? Does not produce TS files? Complains that it cannot find language files?

wysota
30th March 2011, 23:08
I have seen this exact same code structure in a recent post from another person. Are you two working together? Is this some kind of school assignment?

liran ritkop
31st March 2011, 09:34
I have seen this exact same code structure in a recent post from another person. Are you two working together? Is this some kind of school assignment?
The last topic was mine also, except that this is different problem, so i opened a new post. (well, i tried to comment there, but I got this massage about a token expired, and i didn't understand what is it, and still don't).


Apart from the obvious typing errors in your first code snippet, what about it "doesn't work"? Doesn't compile? Doesn't output in Swahili? Does not produce TS files? Complains that it cannot find language files?
I know it doesn't look good, cause i shortened it in order to place it here.
It compile, It produce TS files, it find language file. It doesn't work in the manner that it doesnt translate the string.
How should i implement a translation with a context in QT_TRANSLATE_NOOP and later on, relate to it?

wysota
31st March 2011, 09:48
I will repeat the same question I asked in the other thread then. Are you doing something with boxes[i].Text after you assign the return value from tr() to it?

liran ritkop
31st March 2011, 10:08
I just display the text the the boxes object contain.
It did worked when i used QT_TR_NOOP in the GeneralStruct object, and later on, in the other object, i use the function tr(), and after "lupdate" i change manually the TS file by changing the context "GeneralStruct" to the object name (where i invoke tr()).
I don't want to do it manually, and i know there is a way with the QT_TRANSLATE_NOOP and translate() with contexts given as arguments.
So how do I implement it and make it work? (work = translate the strings)

wysota
31st March 2011, 10:25
The code looks correct. Your manual tweaking but be breaking something.