Results 1 to 8 of 8

Thread: Dynamic Language Switching

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Dynamic Language Switching

    Hi. I've got a problem. I'd like to do dynamic language switching in my application, but there's a problem. In my book it is explained how to do it designing forms manually, not by designer. I created forms using designer. The problem is, that function createLanguageMenu() is very different than usual. And (I think) I can't make it by subclassing QMainWindow. Do you know what I mean? Have you got any ideas how to do it ?Regards

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Dynamic Language Switching

    Quote Originally Posted by Salazaar View Post
    Hi. I've got a problem. I'd like to do dynamic language switching in my application, but there's a problem. In my book it is explained how to do it designing forms manually, not by designer. I created forms using designer. The problem is, that function createLanguageMenu() is very different than usual. And (I think) I can't make it by subclassing QMainWindow. Do you know what I mean? Have you got any ideas how to do it ?Regards
    Chapter 17 from http://trolltech.com/developer/documentation/books/2 german version ...
    the code is not on cd....

    http://doc.trolltech.com/4.3/qtranslator.html detroy truncate the actual language and load a new ... translator file... on qmainwindow .

    http://doc.trolltech.com/4.3/qcoreap...moveTranslator
    http://doc.trolltech.com/4.3/qcoreap...tallTranslator

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Dynamic Language Switching

    I'm not sure if I understood the problem but hopefully this wiki article helps: Dynamic translation.
    J-P Nurmi

  4. #4
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dynamic Language Switching

    Thanks a lot, I'll read it. Regards

  5. #5
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dynamic Language Switching

    No, that links didn't solve the problem. The problem is, that createLanguageMenu is different that, let's say, createFileMenu, and I am designing forms in designer, so I can't change createLanguageMenu without accessing ui_.h file code. And I'd like to know, how to do dynamic language switching when you were designing forms by designer, not manually. Regards

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Dynamic Language Switching

    It's done in code for the reason that usually you don't want a static hard coded language menu (done in designer) but rather a dynamic menu loaded according to detected language files. This way new language files can be added later without recompiling the application.
    J-P Nurmi

  7. #7
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dynamic Language Switching

    Quote Originally Posted by jpn View Post
    It's done in code for the reason that usually you don't want a static hard coded language menu (done in designer) but rather a dynamic menu loaded according to detected language files. This way new language files can be added later without recompiling the application.
    I don't understand I'd like dynamic language switching, without necessity to rebuild application or run it again

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Dynamic Language Switching

    Quote Originally Posted by Salazaar View Post
    I don't understand I'd like dynamic language switching, without necessity to rebuild application or run it again
    You can do this with actions created in designer. You still might want to instantiate a QActionGroup or QSignalMapper in code instead of creating separate slots for each action. Then just switch the language according to the action (it's up to you whether you use text, objectName, data, or something else).

    However, I was talking about flexibility with adding new translations. If you create language actions in designer, you will have to add a new action and recompile the application if you later decide to add a new translation to your application.
    J-P Nurmi

Similar Threads

  1. Switching static to dynamic ui loading
    By s_a_white in forum Newbie
    Replies: 4
    Last Post: 26th June 2006, 15:57

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.