Results 1 to 5 of 5

Thread: how to use tr() for QMessageBox?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to use tr() for QMessageBox?

    What version of Qt are you using?

    This should work for 4.2.2 (it does for me):

    Qt Code:
    1. QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes");
    2. QT_TRANSLATE_NOOP("QDialogButtonBox", "&No");
    To copy to clipboard, switch view to plain text mode 

    Check QDialogButtonBox.cpp for other strings to translate

  2. The following user says thank you to Byngl for this useful post:

    gfunk (20th November 2007)

  3. #2
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to use tr() for QMessageBox?

    You should load a Qt library translator. There are some translators in %QTDIR%\translations which translate every user visible text in Qt library. French one is incomplete, but you may modify it in linguist.

    Qt Code:
    1. QTranslator *qtTranslator = new QTranslator;
    2. QTranslator *appTranslator = new QTranslator;
    3. qtTranslator->load(
    4. QString("qt_%1").arg(lang),
    5. QLibraryInfo::location(QLibraryInfo::TranslationsPath)
    6. );
    7. appTranslator->load(...); // Load your translator
    8.  
    9. installTranslator(appTranslator);
    10. installTranslator(qtTranslator);
    To copy to clipboard, switch view to plain text mode 

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.