Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't have application menu bar in english on OSX french
QtWS25 Last Chance

Can't have application menu bar in english on OSX french

Scheduled Pinned Locked Moved Solved General and Desktop
translationsos xmenubarqmlqt 5.5.1
12 Posts 2 Posters 5.4k Views
  • 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.
  • N Offline
    N Offline
    nelbok
    wrote on 27 Jan 2016, 09:54 last edited by
    #1

    Hello,

    I would like to launch application in a other language than the OSX settings.
    So I have followed this documentation: http://doc.qt.io/qt-5/internationalization.html#enabling-translation
    It works fine for other langages like Spanish or Chinese.

    But when it comes to english, QTranslator::load fail to load the qt english translation file.
    So I have my application in english but not the OSX application menu bar.

    What I am doing wrong ?

    Here the code:

    QString lang = "en"; // Or de, es, it, ru, ...
    QTranslator *translator = new QTranslator(this);
    
    bool loadOK = translator->load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    bool installOK = false;
    if (loadOK)
        installOK = qApp->installTranslator(translator);
    else
        translator->deleteLater();
    
    qDebug() << "Qt translations path: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    qDebug() << "Translator: " << "qt_" + lang << " - load: " << loadOK << " - install: " << installOK;
    
    /* For en, the result are:
        Qt translations path: "/Users/[username]/Qt/5.5/clang_64/translations"
        Translator: "qt_en" - load: false - install: false
        */
    

    Regards,

    nelbok

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Jan 2016, 23:50 last edited by
      #2

      Hi and welcome to devnet,

      The menu bar is a special case in OS X. Take a look here, it describes how to handle the menu bar translation.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • N Offline
        N Offline
        nelbok
        wrote on 1 Feb 2016, 09:12 last edited by
        #3

        Thanks SGaist,

        I have tested your link, but it doesn't work. So i tested other things and i found something strange.
        With QtWidgets, the application menu bar is translated nice. I don't have the problem.
        But with QML, i have the problem.

        So i have the problem only with QML. Actually, i have tested on :

        • Mountain Lion: Qt 5.5.1 and xcode 5.1.1
        • Mavericks: Qt 5.5.1 and xcode 5.1.1

        There are a special thing to do with QML ?

        Regards,

        nelbok

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 Feb 2016, 21:50 last edited by
          #4

          Can you share a minimal sample project on e.g. github that shows that behavior ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply 8 Feb 2016, 12:00
          0
          • S SGaist
            3 Feb 2016, 21:50

            Can you share a minimal sample project on e.g. github that shows that behavior ?

            N Offline
            N Offline
            nelbok
            wrote on 8 Feb 2016, 12:00 last edited by
            #5

            Sorry for the wait.

            Here two examples :

            • one with Qt Widgets where all work well : https://github.com/nelbok/SRPTest/tree/master/widgetsMenuBar
            • one with Qt Quick where i can't have English on OSX French : https://github.com/nelbok/SRPTest/tree/master/quickMenuBar

            For the moment, i have a work around. I create a english translation to manually set the correct values.
            I have getted the source of translations module with the Qt installer to have the key translations...

            <?xml version="1.0" encoding="utf-8"?>
            <!DOCTYPE TS>
            <TS version="2.1" language="en">
            <context>
                <name>MAC_APPLICATION_MENU</name>
                <message>
                    <source>Services</source>
                    <translation>Services</translation>
                </message>
                <message>
                    <source>Hide %1</source>
                    <translation>Hide %1</translation>
                </message>
                <message>
                    <source>Hide Others</source>
                    <translation>Hide Others</translation>
                </message>
                <message>
                    <source>Show All</source>
                    <translation>Show All</translation>
                </message>
                <message>
                    <source>Preferences...</source>
                    <translation>Preferences...</translation>
                </message>
                <message>
                    <source>Quit %1</source>
                    <translation>Quit %1</translation>
                </message>
                <message>
                    <source>About %1</source>
                    <translation>About %1</translation>
                </message>
            </context>
            </TS>
            

            Regards,

            nelbok

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 Feb 2016, 23:44 last edited by SGaist 2 Dec 2016, 23:44
              #6

              Since my system is in english I've tested both applications loading the german translation file and both worked correctly but I have Qt version that is more recent than you.

              Can you check again with the 5.6 Beta ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply 13 Feb 2016, 09:41
              0
              • S SGaist
                12 Feb 2016, 23:44

                Since my system is in english I've tested both applications loading the german translation file and both worked correctly but I have Qt version that is more recent than you.

                Can you check again with the 5.6 Beta ?

                N Offline
                N Offline
                nelbok
                wrote on 13 Feb 2016, 09:41 last edited by
                #7

                Hello,

                After downloaded and installed qt-opensource-mac-x64-clang-5.6.0-beta.dmg.
                On my OSX french and for the QML project, it does not work, i have the application menu bar in french and not in english.

                Also, when i run the two project, they say that they can't load qt_en in the output log.

                Regards,

                nelbok

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 13 Feb 2016, 23:35 last edited by
                  #8

                  Does it also fail if you change qt_en by qt_de ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply 14 Feb 2016, 11:18
                  0
                  • S SGaist
                    13 Feb 2016, 23:35

                    Does it also fail if you change qt_en by qt_de ?

                    N Offline
                    N Offline
                    nelbok
                    wrote on 14 Feb 2016, 11:18 last edited by
                    #9

                    When i change lang to de, with Qt 5.5.1 or 5.6, it works fine.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 15 Feb 2016, 23:05 last edited by
                      #10

                      So it seems that for some reason there's something funky with the english translation going on...

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 21 Feb 2016, 20:35 last edited by
                        #11

                        I just realized, Qt is already written in english so it's pretty likely that the qt_en.qm file is empty. So if you need english translation of your non-english written application, you have to provide the english translation of your application. Personally, I'd recommend writing your application in english and provide translations for the other languages.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        N 1 Reply Last reply 23 Feb 2016, 06:21
                        0
                        • S SGaist
                          21 Feb 2016, 20:35

                          I just realized, Qt is already written in english so it's pretty likely that the qt_en.qm file is empty. So if you need english translation of your non-english written application, you have to provide the english translation of your application. Personally, I'd recommend writing your application in english and provide translations for the other languages.

                          N Offline
                          N Offline
                          nelbok
                          wrote on 23 Feb 2016, 06:21 last edited by
                          #12

                          Hello,

                          That not the problem here.
                          If i understand correctly, the OSX Application Menu is translated by Qt, not my application.
                          The problem occurs only with QtQuick and on a OSX no-english.

                          So why i must do give a translated file created by me for QtQuick and not for QtWidgets ? (And not the translated files qt)

                          Regards,

                          nelbok

                          1 Reply Last reply
                          0

                          4/12

                          3 Feb 2016, 21:50

                          topic:navigator.unread, 8
                          • Login

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