[SOLVED] Mac application menu items not translated
-
wrote on 7 Feb 2014, 10:08 last edited by
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.
-
wrote on 10 Feb 2014, 17:52 last edited by
Really? :-(
-
wrote on 18 Feb 2014, 16:53 last edited by
Hi,
try e.g. this:
http://qt-project.org/forums/viewthread/21134 -
wrote on 18 Feb 2014, 17:00 last edited by
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.
-
Hi,
Can you provide a sample project that reproduce the behavior ?
-
wrote on 9 Jul 2014, 20:21 last edited by
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.
-
wrote on 28 Jul 2014, 03:46 last edited by
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!
-
wrote on 28 Jul 2014, 13:26 last edited by
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.