Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: Switch QTranslator at runtime?

  1. #21
    Join Date
    May 2006
    Posts
    108
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    35
    Thanked 2 Times in 1 Post

    Question Re: Switch QTranslator at runtime?

    the problem is not tr() or QT_TR_NOOP() the problem is i use

    Qt Code:
    1. tr("Any information") + "<br><br>" + tr("for more text look next page");
    To copy to clipboard, switch view to plain text mode 

    and translate it

    Qt Code:
    1. tr(infoData->Text.toLatin1())
    To copy to clipboard, switch view to plain text mode 

    That’s the reason why your last example and my code not work. My trial with QT_TR_NOOP() has work because i have use only one line text.

    That’s a look of a little orignal code with dummy text.
    Qt Code:
    1. QString text = tr("TextTextText") + "<br><br>"+ tr("TextTextText") + "<br><br>"
    2. "<table width=\"100%\">"
    3. "<tr>"
    4. "<td width=\"25%\" align=\"center\">" + tr("TextTextText") + "</td>"
    5. "<td width=\"25%\" align=\"center\">" + tr("TextTextText") + "</td>"
    6. "<td width=\"25%\" align=\"center\">" + tr("TextTextText") + "</td>"
    7. "<td width=\"25%\" align=\"center\">" + tr("TextTextText") + "</td>"
    8. "</tr>"
    9. "<tr>"
    10. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    11. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    12. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    13. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    14. "</tr>"
    15. "<tr>"
    16. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    17. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    18. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    19. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    20. "</tr>"
    21. "<tr>"
    22. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    23. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    24. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    25. "<td align=\"center\">" + tr("TextTextText") + "</td>"
    26. "</tr>"
    27. "</table>";
    To copy to clipboard, switch view to plain text mode 

    I can translate the text if i set all in tr() but that’s looks like dirty in the linguist and it’s hard to translate. Can you tell me how can i translate it without html?

    Thanks in advance,

    Whitefurrows

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Switch QTranslator at runtime?

    You could for example place markers in the plain text, then perform the translations and then substitute markers with HTML code. Or even don't use custom markers but the ones provided by Qt (%1, %2, etc.) so you can use QString::arg to substitute them.

  3. #23
    Join Date
    May 2006
    Posts
    108
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    35
    Thanked 2 Times in 1 Post

    Question Re: Switch QTranslator at runtime?

    Hi,

    a big sorry to you, it’s my mistake i have forget to clear QList, tr() and QString::arg() worke fine. A lot of thanks to you for your splendid help and patience.

    Best regards,

    Whitefurrows
    Last edited by whitefurrows; 6th November 2006 at 13:18.

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
  •  
Qt is a trademark of The Qt Company.