Results 1 to 7 of 7

Thread: Translate my app (dynamic)

  1. #1
    Join Date
    Sep 2010
    Location
    Tel Aviv, Israel
    Posts
    26
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Translate my app (dynamic)

    I have some troubles...
    I declare an array of string in a global object like that:
    Qt Code:
    1. GeneralStruct::GeneralStruct(QWidget *parent):QWidget(parent){
    2. greeting_strings[0] = QT_TRANSLATE_NOOP("Global, "France");
    3. greeting_strings[1] = QT_TRANSLATE_NOOP("Global, "Energy");
    4. greeting_strings[2] = QT_TRANSLATE_NOOP("Global, "Caps");
    5. greeting_strings[3] = QT_TRANSLATE_NOOP("Global, "Switch");
    6. };
    To copy to clipboard, switch view to plain text mode 
    and than i place in another object the translated texts in that way:
    Qt Code:
    1. for (i=0; i<Number_Of_Boxes; i++)
    2. boxes[i].Text = QCoreApplication::translate("Global", generalStructObject->greeting_strings[i]);
    To copy to clipboard, switch view to plain text mode 

    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..

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Translate my app (dynamic)

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Translate my app (dynamic)

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Sep 2010
    Location
    Tel Aviv, Israel
    Posts
    26
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Translate my app (dynamic)

    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?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Translate my app (dynamic)

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Sep 2010
    Location
    Tel Aviv, Israel
    Posts
    26
    Thanks
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Translate my app (dynamic)

    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)

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Translate my app (dynamic)

    The code looks correct. Your manual tweaking but be breaking something.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Dynamic Translate
    By liran ritkop in forum Qt Programming
    Replies: 14
    Last Post: 30th March 2011, 12:22
  2. Translate help framework's gui
    By yagabey in forum Qt Programming
    Replies: 0
    Last Post: 14th October 2010, 07:38
  3. translate on fly
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2009, 14:21
  4. QGraphicsView::translate
    By chaoticbob in forum Qt Programming
    Replies: 4
    Last Post: 30th November 2008, 10:30
  5. QGraphicsView::translate
    By peace_comp in forum Qt Programming
    Replies: 4
    Last Post: 7th April 2008, 10:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.