Results 1 to 5 of 5

Thread: qmake and localization

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: qmake and localization

    In that case you can move the definition of QTranslator object into your main window class (or everywhere else, just somewhere that'll keep it) and load it like before:

    at mainwindow.h file:
    Qt Code:
    1. private:
    2. QTranslator translator;
    To copy to clipboard, switch view to plain text mode 

    In MainWindow's constructor before setupUi():
    Qt Code:
    1. translator.load("path/to/qm/file/cs_CZ.qm");
    2. qApp->installTranslator(&translator);
    To copy to clipboard, switch view to plain text mode 

    When you want to change language at runtime you just load the new language and retranslate the ui:
    Qt Code:
    1. translator.load("path/to/qm/file/en_US.qm");
    2. ui->retranslateUi(this);
    To copy to clipboard, switch view to plain text mode 

    This way, you install the translator once and just change it's loaded language whenever needed.

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

    gordebak (11th November 2012)

  3. #2
    Join Date
    May 2010
    Posts
    3
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake and localization

    I just wanted to load the appropriate translation according to the system locale in the first startup. I did it reading the documentation.

    Thank you very much.

Similar Threads

  1. Localization - shortDayName - Raspberry Pi
    By scls19fr in forum Qt Programming
    Replies: 0
    Last Post: 25th October 2012, 17:18
  2. Localization of library
    By realdarkman71 in forum Newbie
    Replies: 0
    Last Post: 27th May 2012, 19:09
  3. Replies: 2
    Last Post: 23rd May 2011, 09:21
  4. Localization for dynamically generated text.
    By vaibhav in forum Qt Programming
    Replies: 10
    Last Post: 14th March 2011, 11:03
  5. Real Time Localization System
    By oswalidos in forum General Programming
    Replies: 3
    Last Post: 22nd September 2009, 19:50

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