Results 1 to 9 of 9

Thread: Internationalisation of Application at run time.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2012
    Location
    Gurgaon, Haryana, India
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Post Internationalisation of Application at run time.

    Hello Everyone,

    I have an application in English. Now i want that user can change language at run time.
    I do that with help of QTranslater,but after install translater i need to retranslate ui.

    Is there any which a can change langauge at run time without retranslating ui.


    Best Regards
    Pardeep Sharma

  2. #2
    Join Date
    May 2012
    Posts
    136
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 27 Times in 24 Posts

    Default Re: Internationalisation of Application at run time.

    What do you mean by changing language without retranslating the ui?

    I use this to translate at runtime:
    Qt Code:
    1. void MainWindow::changeEvent(QEvent* event)
    2. {
    3. if (event->type() == QEvent::LanguageChange)
    4. {
    5. // retranslate designer form
    6. ui->retranslateUi(this);
    7.  
    8. // retranslate other widgets which weren't added in designer
    9. retranslate();
    10. }
    11.  
    12. // remember to call base class implementation
    13. QMainWindow::changeEvent(event);
    14. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Internationalisation of Application at run time.

    What do you mean by changing language without retranslating the ui?
    It means the ui->retranslateUi(this); that you're calling. That what he don't want to call in his program.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  4. #4
    Join Date
    May 2012
    Posts
    136
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 27 Times in 24 Posts

    Default Re: Internationalisation of Application at run time.

    If that is the case then the answer is no there is no other option

  5. #5
    Join Date
    Oct 2012
    Location
    Gurgaon, Haryana, India
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Internationalisation of Application at run time.

    Thanks for your reply.

    In my application there is scenario where pushbutton have different text depending upon situation.

    I mean to say initially push button have text(say "Hello") & after clicking them its text will be change(say "Bye"),then how to handle this .

    And in re-translation of ui we set initial text of widget. If user change language after clicking button then what to do??

  6. #6
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Internationalisation of Application at run time.

    Yup that you can also do from this.
    Check for the returned text like this ;-

    Qt Code:
    1. if(ui->pushButton->text() == "Hello")
    2. <Set the hello translation code here>
    3. else
    4. <Set the bye translation code here>
    To copy to clipboard, switch view to plain text mode 

    Write it in separate method and call it from the changeEvent().
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  7. The following user says thank you to sonulohani for this useful post:

    Pardeep (8th October 2012)

  8. #7
    Join Date
    Oct 2012
    Location
    Gurgaon, Haryana, India
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Internationalisation of Application at run time.

    Sonulohani thanks for your valuable help.

    Tell me one more thing is there any why by which i can define all string used by widgets to display text, in seperate file. & At any time if user want to change string he/she can easily can change string from that file & that string reflect changes in both .ts & .qm file automatically in application & there is no need to run lupdate & irelease again??

  9. #8
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    29
    Thanked 50 Times in 47 Posts

    Default Re: Internationalisation of Application at run time.

    That i think is not possible cause for translation it always load qm file. Or use QLocale instead.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

Similar Threads

  1. Real time QT application?
    By marc2050 in forum Newbie
    Replies: 1
    Last Post: 8th June 2011, 06:08
  2. wait the application for some time..
    By mohanakrishnan in forum Qt Programming
    Replies: 3
    Last Post: 9th December 2009, 08:22
  3. Replies: 10
    Last Post: 10th March 2008, 12:28
  4. Application crashes at launch-time
    By Salazaar in forum Newbie
    Replies: 70
    Last Post: 22nd June 2007, 01:11
  5. Problem with internationalisation
    By piotrpsz in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2006, 16:53

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.