Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to change language in QMenu in QMainWindow class
Forum Updated to NodeBB v4.3 + New Features

How to change language in QMenu in QMainWindow class

Scheduled Pinned Locked Moved Mobile and Embedded
15 Posts 4 Posters 9.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saskic
    wrote on last edited by
    #1

    Hello all,

    I'm working on Qt application for my Nokia 5230 with Qt creator. It seems that developer guys did a nice work with Qt designer - it made my work much easier, creating *.ui classes and connecting them with my code. Well done.

    However, I got a problem with ui class for QMainWindow when developing application for Croatian language. When my program runs, I see English instead of Croatian on QMenu buttons (two default buttons on touchscreen devices). It's written "Options" and "Exit" until I press some action in QMenu, and then it translates to Croatian.
    In the main source class of my application I've installed translator:

    @ QString filename = QString("myproject_%1").arg(QLocale::system().name());
    QTranslator translator;
    translator.load(filename.toLower(),qApp->applicationDirPath());
    a.installTranslator(&translator);@

    And add it to *.pro file.
    (I've also edit translation file in Qt linguist but text "Options", and "Exit", which are default names for QMenu buttons appear nowhere).
    I've also set "locale" property of QMainWindow class to Croatian, but it does not make any effect. Can I change those values in constructor of QMainWindow? And how'
    The same thing also happens when making selection with QComboBox - it's written "Select", instead "Odaberi" :(

    Thank you very much in advance.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      disperso
      wrote on last edited by
      #2

      Do you mean that when you press the menu, "Options" and "Exit" are translated to Croatian? Or do you mean that the contents of the menu are in Croatian, but "Options" and "Exit" are still in English?

      PS: Please, if possible, put your code between two "@" signs (edit the post), so it will be formatted as code.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kamalakshantv
        wrote on last edited by
        #3

        Interesting never tried this out before. But usually in Symbian the .pkg file defines the lang supported by the app. Can you check what is the supported lang in the qt generated .pkg file

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Saskic
          wrote on last edited by
          #4

          I love this forum, you are really fast.
          When I press "Options" on my menu, "Options" and "Exit" are translated to Croatian.
          Hm, my project_installer.pkg file says :

          ; Language
          &EN

          I would never came to idea to check it. Do you have any suggestions how I can change this to Croatian?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kamalakshantv
            wrote on last edited by
            #5

            [quote author="Saskic" date="1292161586"]I love this forum, you are really fast.
            When I press "Options" on my menu, "Options" and "Exit" are translated to Croatian.
            Hm, my project_installer.pkg file says :

            ; Language
            &EN

            I would never came to idea to check it. Do you have any suggestions how I can change this to Croatian? [/quote]

            If you change the lang to croatian it would fix your problem for sure. But that its not the right way to edit the pkg directly in Qt. In Symbian you could have done that. I don't know what the right approach would be.

            Also changing the lang will also require you to generate .rsc file according to the lang pack defined. So if we change it manually, we will have to generate the rsc files also manually.

            I would suggest this as the last workaround.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Saskic
              wrote on last edited by
              #6

              Thanks a lot, so after surfing a bit around, I've found the following article:
              http://developer.symbian.org/wiki/Apps:Deploying_a_Qt_Application#Change_the_language_of_the_installation

              So, I added to my .pro file, (symbian configuration) the following code

              @languages = "&HR"
              my_deployment.pkg_prerules = languages
              DEPLOYMENT += my_deployment@

              Now my .pkg file say it's croatian, by anyway, I got English in my QMenu...again :(

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kamalakshantv
                wrote on last edited by
                #7

                You need to test it in a device with croatian lang pack installed.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Saskic
                  wrote on last edited by
                  #8

                  is Nokia 5230 with a system running in Croatian enough? or I need to install some language pack for Qt :S on my phone (confused :))?

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kamalakshantv
                    wrote on last edited by
                    #9

                    Check what languages are supported in your device by going to its settings.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Saskic
                      wrote on last edited by
                      #10

                      Croatian is default one :(

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        kamalakshantv
                        wrote on last edited by
                        #11

                        In that case it should have worked. May be we are missing something else. Check if we have .lHR file generated. This would be your croatian specific language resource.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Saskic
                          wrote on last edited by
                          #12

                          No, unfortunately, there is no such file. Any solutions?

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kamalakshantv
                            wrote on last edited by
                            #13

                            Usually in symbian, .loc file contains localized strings. So if its english it would be .l01, the 01 is the lang code for english. Similarly there would be one for croatian also.

                            Does other native apps show the option menu properly in croatian and only your app displays it in english.

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              Saskic
                              wrote on last edited by
                              #14

                              I've checked my .loc file and here is the content:

                              @
                              #ifdef LANGUAGE_SC
                              #define STRING_r_short_caption "Lista"
                              #define STRING_r_caption "Lista"
                              #elif defined LANGUAGE_45
                              #define STRING_r_short_caption "Lista"
                              #define STRING_r_caption "Lista"
                              #else
                              #define STRING_r_short_caption "Lista"
                              #define STRING_r_caption "Lista"
                              #endif
                              @

                              Code for Croatian is 45 so, I assume this is correct. Unfortunately, these problems I have only with my application, the other ones running on my phone (i.e. Contacts) display Menu properly, in Croatian.

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                raimisz
                                wrote on last edited by
                                #15

                                Hi, i have similar problem

                                all the qt application that i create with qt have "Options" and i can't translate it to other language. is there any solution for this? i have to translate my application to "Latvian". my phone (nokia 5230) supports "Latvian" and in other Nokia applications "Options" is "Iespējas" (Latvian "Options")

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved