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



On Oct 11, 2012, at 5:25 AM, Henrik Brautaset Aronsen <henrik synth no> wrote:

> Hi John.
> 
> Hope it's OK that I contact you directly by mail.  According to what I could find, you speak Gtk and OSX fluently :)
> 
It's not. Please use the gtk-osx-users list. For your convenience, I' ve cc'd it on this reply, so you need only subscribe.

> 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.

Regards,
John Ralls


[1] https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html#//apple_ref/doc/uid/10000051i-CH6

[2] https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/miscellaneous/foundation_functions/reference/reference.html#//apple_ref/c/macro/NSLocalizedString


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