Results 1 to 3 of 3

Thread: lupdate not loading all strings

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: lupdate not loading all strings

    Hello!

    I recently started working with translations and I noticed that some of my strings weren't compiled to the .ts files by lupdate, notably those which were generated inside a for() loop translating the strings from an array:

    Qt Code:
    1. const char* myStrings[] = { "String 1", "String 2", "String 3" };
    2.  
    3. for (int aaa = 0; aaa < 3; aaa++)
    4. {
    5. myLabel[aaa]->setText(tr(myStrings[aaa]));
    6. }
    To copy to clipboard, switch view to plain text mode 

    I did some research in the Qt Linguist Manual and I noticed that it repeatedly talks about "human readable strings" or "user-visible text". Does this means that strings set to translation as in the code above would never work? And I need to write them separatedly? :

    Qt Code:
    1. myLabel[0]->setText(tr("String 1"));
    2. myLabel[1]->setText(tr("String 2"));
    3. myLabel[2]->setText(tr("String 3"));
    To copy to clipboard, switch view to plain text mode 


    Thanks,

    Momergil


    Added after 1 47 minutes:


    I found the answer I seek: use QT_TRANSLATE_NOOP or QT_TR_NOOP arround the strings of the array.
    Last edited by Momergil; 31st July 2014 at 20:44.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: lupdate not loading all strings

    For further readers, I just found this old post (it's about Qt3 \o/) that give some tips about translating with Qt, including commentaries about not using the two macros I just presented as solution to my problem . I'll still testing the shown alternatives, but they seem reasonable.
    May the Lord be with you. Always.

  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: lupdate not loading all strings

    The paper doesn't say anywhere you shouldn't use QT_TR_NOOP. It says you should use it together with tr().
    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. Replies: 4
    Last Post: 9th August 2012, 21:08
  2. Replies: 3
    Last Post: 2nd August 2012, 13:46
  3. Replies: 13
    Last Post: 6th February 2009, 21:27
  4. 4.2 and lupdate
    By Byngl in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 03:55
  5. lupdate *.pro troubles
    By jeff_s in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2006, 10:07

Tags for this Thread

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.