Re: [gtk-osx-users] GTK and localization



On Oct 11, 2012, at 7:34 AM, Dirk Hohndel <dirk hohndel org> wrote:

> John Ralls <jralls ceridwen us> writes:
> 
>>> I'm currently looking into localization of Subsurface [1], a dive log program created by Linus Torvalds.
>>> 
>>> We're using gtk2, gtk-mac-integration and gettext, but somehow some of the Mac specific menu items doesn't get localized.  I have a Norwegian setup, so I tried adding a basic /Applications/Subsurface.app/Contents/Resources/no.lproj/GtkOSXApplication.strings with content like:
>>> 
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
>>> <plist version="1.0">
>>> <dict>
>>> <key>Preferences</key>
>>> <string>Valg</string>
>>> </dict>
>>> 
>>> It doesn't seem to work, though.
>> 
>> No, why would it? ICU strings files aren't XML. See the examples provided with GtkosxApplication or "String Resources" [1] in the Apple Developer Documentation. But that's not the only problem: In order for the ICU localization to work, the string constant must be added to the menu with one of the NSLocalizedString [2] functions. I doubt that you did that for your Preferences menu item.
>> 
>>> 
>>> So:
>>> 
>>> 1) Is it possible to skip the *.lproj altoghether and use gettext for all localization?
>> 
>> Only by rewriting the Apple menu code in gtkosxapplication_quartz.c. Patches welcome.
>> 
>>> 2) Some items in the Apple menu are localized when running ./subsurface directly, while others are translated when running Subsurface.app.  Is there a way to get around this?
>> 
>> The Apple menu items localized with NSLocalizedStringFromTable() don't translate when your program is launched from the command line because launch services isn't involved so the bundle links, which the Apple localization functions use to find the strings files, aren't created. I suspect that the menu items that are translated in that case are ones that you've added (like your preferences example) with gtkosx_application_insert_app_menu_item(). If those aren't getting localized when you launch with launch services (clicking in Finder or using open(1)) then you've messed something up. You'll have to debug that in more detail to figure out what. 
> 
> So if I understand you correctly, if we simply don't use any of the
> default menu item names (like "New" for GTK_STOCK_NEW) but instead make
> them explicit when building the menu from hand, this shouldn't affect us
> at all, correct?
> 
> Henrik, can you test what I pushed a few minutes ago and see if that
> works on your Mac with the Norwegian translations (you obviously need to
> edit your .po file, first)

Sorry, I don't follow you. "New" normally lives in the File menu. The normal gettext translations should apply, and if you're using the stock menu items they're even provided by Gtk, so you need only include gtk20.mo for each language you support in your bundle. More generally, if your localization works in X11, it should work without change in OSX. If it's working when you run it from your jhbuild shell but not after bundling, then you probably aren't getting all of the necessary mo files installed in the bundle.

So, build what menu by hand? Why?

Regards,
John Ralls



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]