开发者

Localizing Application (main) Menu?

I'm porting a UNIX application which uses the Qt framework (Qt, not QuickTime) to Mac/Cocoa. Life is good, generally. Qt has a Cocoa implementation, so with some Objective-C++, I've gotten lots of Mac-specific bits working.

I can't get the main menu (i.e., the Application menu) to translate. It's set using:

    [NSApp setMainMenu:menu];

I've got my en.lproj, ja.lproj, fr.lproj, etc. folders set up, and they have InfoPlist.strings files. Qt handles the internal localization of application-specific menus. But if I switch languages开发者_运维技巧, I still have "Quit Avogadro".

I've read through as much documentation in the Mac Dev Center as possible, but can't find an answer.

I know that strings in the mainMenu are handled by Cocoa -- they're not localized in any Apple application. Any ideas on the magic trigger? Any ideas for where to look?

Thanks in advance!


I wanted to add some information to this, in case someone else is looking to do this. I was also trying to modify the application main menu and I was attempting to set it in the awakeFromNib method. This never worked because according to this thread we need to modify the application main menu AFTER the menu has been set. Otherwise, the application will always use the title found in its Info.plist. So, this means that if you ever change your application's name, you never have to update your application's MainMenu.nib.


It turns out that this was a Qt bug: https://bugreports.qt-project.org//browse/QTBUG-4463

It's fixed in Qt 4.7 and later

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜