Results 1 to 3 of 3

Thread: UI translation

  1. #1
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default UI translation

    Hi to all!
    I generate ui_mainwindow.h from form where is all interface. Also I create context menu for tray icon after setupUI():
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
    2. ui(new Ui::MainWindow), m_signalsIsBlocked(false)
    3. {
    4. ui->setupUi(this);
    5. //........................
    6. //..........................
    7. CreateActions();
    8. //......................
    9. }
    10.  
    11. void MainWindow::CreateActions()
    12. {
    13. minimizeAction = new QAction(QObject::tr("Mi&nimize"), this);
    14. connect(minimizeAction, SIGNAL(triggered()), this, SLOT(on_actionMinimize_triggered()));
    15.  
    16. maximizeAction = new QAction(tr("Ma&ximize"), this);
    17. connect(maximizeAction, SIGNAL(triggered()), this, SLOT(on_actionMaximize_triggered()));
    18.  
    19. restoreAction = new QAction(tr("&Restore"), this);
    20. connect(restoreAction, SIGNAL(triggered()), this, SLOT(on_actionRestore_triggered()));
    21.  
    22. quitAction = new QAction(tr("&Quit"), this);
    23. connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    24. }
    To copy to clipboard, switch view to plain text mode 
    Then I make *.ts by using lupdate, after that translate strings and make *.qm by using lrelease.

    Then I add code to main():
    Qt Code:
    1. QApplication a(argc, argv);
    2. QTranslator appTrans;
    3. QString langFile(":/i18n/vdynclient_ru_RU.qm"); // Russian translation
    4. appTrans.load(langFile);
    5. a.installTranslator(&appTrans);
    To copy to clipboard, switch view to plain text mode 
    But I get translated strings only for tray context menu, but not for all interface.
    I tried to check translation by:
    Qt Code:
    1. QString transl = appTrans.translate("MainContext", "Your E-mail:");
    To copy to clipboard, switch view to plain text mode 
    And got correct translation, cause one exists, but why isn`t it displayed on the form (every time I see only english words)?
    Can anybody help, please?

  2. #2
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: UI translation

    Hi Annihilator,

    Can you please post a working example?
    It would be easier to help you in this way.

    Regards,
    Wladek
    One second is long, everything longer than two seconds is definitely too long.

  3. #3
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: UI translation

    Hi wladek. I resolved this issue. Just created another project and place all files in one folder. I placed file in separate folders (src, ui) before that. I think this was a problem.

    Regards,
    Ruslan

Similar Threads

  1. translation
    By weixj2003ld in forum Qt Programming
    Replies: 8
    Last Post: 31st May 2010, 01:01
  2. Translation of UI
    By elizabeth.h1 in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 11:01
  3. problem with Translation
    By #andi# in forum Newbie
    Replies: 1
    Last Post: 9th August 2009, 15:14
  4. setText translation
    By weixj2003ld in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2009, 15:59
  5. Translation
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2007, 17:45

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.