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. [SOLVED] Mac application menu items not translated
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Mac application menu items not translated

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.9k 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.
  • J Offline
    J Offline
    janfaroe
    wrote on 7 Feb 2014, 10:08 last edited by
    #1

    Hi all,

    I'm having problems localizing the Application menu items on Mac OS. The rest of the application translates just fine, the application menu is translated when I launch the application from Qt Creator, but when the application is "on its own" after running macdeployqt on a release bundle, it's reverted to the original language (english).

    I've added the necessary directories/files within the bundle:

    @<bundle dir>/Contents
    Resources
    da.lproj
    locversion.plist@

    (in this case for Danish), where locversion.plist contains

    @<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>LprojCompatibleVersion</key>
    <string>123</string>
    <key>LprojLocale</key>
    <string>da</string>
    <key>LprojRevisionLevel</key>
    <string>1</string>
    <key>LprojVersion</key>
    <string>123</string>
    </dict>
    </plist>@

    Even though this may not be necessary(?), I've added strings like this in my application as a desperate resort:

    @QCoreApplication::translate("Mac Application Menu", "Services");
    QCoreApplication::translate("Mac Application Menu", "Hide %1");@

    and translated them of course. Still, no Danish application menu. What is the secret of this seemingly black art? Looking around the net, it seems like others are struggling too.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      janfaroe
      wrote on 10 Feb 2014, 17:52 last edited by
      #2

      Really? :-(

      1 Reply Last reply
      0
      • H Offline
        H Offline
        h0r4r
        wrote on 18 Feb 2014, 16:53 last edited by
        #3

        Hi,
        try e.g. this:
        http://qt-project.org/forums/viewthread/21134

        1 Reply Last reply
        0
        • J Offline
          J Offline
          janfaroe
          wrote on 18 Feb 2014, 17:00 last edited by
          #4

          Thanks for the suggestion, however, I already came across that thread, and did as suggested (although programmatically):

          QCoreApplication::translate("Mac Application Menu", "Services");
          QCoreApplication::translate("Mac Application Menu", "Hide %1");
          ....

          These strings do show up in the .ts files when running lupdate.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 Feb 2014, 21:19 last edited by
            #5

            Hi,

            Can you provide a sample project that reproduce the behavior ?

            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
            • B Offline
              B Offline
              bootchk
              wrote on 9 Jul 2014, 20:21 last edited by
              #6

              But doesn't QCA.translate() return the translation for the given string? What good does it do your program, since Qt is building the menu, on behalf of your app? Oh, I see, you just want to force the translation into your .ts files.

              I would guess that your programmatic translation doesn't work because you misspelled the context, which is something like MAC_APPLICATION_MENU in the Qt code. So if you use that exact context in your code snippet, run lupdate, use linguist to translate, etc. and your app installs a translator for the resulting .qm file, then the Qt library, when building the mac app menu and using that context, will find your translations.

              I could be wrong, and I am struggling too.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                janfaroe
                wrote on 28 Jul 2014, 03:46 last edited by
                #7

                bootchk: Thanks for your input - it does indeed work when changing the context string to "MAC_APPLICATION_MENU"! I didn't put too much importance in the context name, but it's obviously necessary in this case.

                Thanks!

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  bootchk
                  wrote on 28 Jul 2014, 13:26 last edited by
                  #8

                  Great. Ideally, one would not need this hack, but instead contribute a translation to the Qt project. (I haven't done it myself, but it would be something like this: enroll as a Qt contributor, clone the latest source repository, run linguist on qttranslations/qt_da.ts and translate the strings for the main menu context, and submit a patch.)

                  I learned that Qt project relies on third parties to contribute translations. In my case 'Undo %1' is untranslated in qt_es.ts (Spanish) for at least a year. I hope Qt is recovering and getting more traction now.

                  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