• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
advice on localizing specific attributes from XML file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

advice on localizing specific attributes from XML file


  • Subject: advice on localizing specific attributes from XML file
  • From: Jesse Grosjean <email@hidden>
  • Date: Thu, 6 Sep 2007 09:59:42 -0400

I"m working on a new version of my Blocks plugin framework. This version will allow for a lot more configuration info to be declared in the plugin.xml configuration files. And some of that information will need to be localized. For instance here's some markup that defines a main menu:

<menu id="com.blocks.BUserInterface.menus.main">
<menuitem title="" id="application" submenu="com.blocks.BUserInterface.menus.main.application" />
<menuitem title="File" id="file" submenu="com.blocks.BUserInterface.menus.main.file" />
<menuitem title="Edit" id="edit" submenu="com.blocks.BUserInterface.menus.main.edit" />
<menuitem title="Window" id="window" submenu="com.blocks.BUserInterface.menus.main.window" />
<menuitem title="Help" id="help" submenu="com.blocks.BUserInterface.menus.main.help" />
</menu>


And in this case the File, Edit, Window, and Help titles all need to be localized. If I were working in a .m file I would just use NSLocalizedString, but I'm not sure what the best way to handle string localization in an XML file is.

Basically I want something that will work like NSLocalizedString(), but has friendlier XML syntax. I'm thinking that I might just append attribute strings that should be localized with a '%'. So the above would turn into:

<menu id="com.blocks.BUserInterface.menus.main">
<menuitem title="" id="application" submenu="com.blocks.BUserInterface.menus.main.application" />
<menuitem title="%File" id="file" submenu="com.blocks.BUserInterface.menus.main.file" />
<menuitem title="ķit" id="edit" submenu="com.blocks.BUserInterface.menus.main.edit" />
<menuitem title="%Window" id="window" submenu="com.blocks.BUserInterface.menus.main.window" />
<menuitem title="%Help" id="help" submenu="com.blocks.BUserInterface.menus.main.help" />
</menu>


That would make the strings easy to detect when I read them into my program, and then I would call [NSBundle localizedStringForKey] on the read in values to get the localized values. This seems like it would work, but it also means that I'll need to duplicate the functionality of genstrings to recognize the new markup that I'm using. Not to bad, but a little pain.

Anyway please let me know if this approach seems to make sense, or if there are better solutions to the problem that I don't know about. My end goal is to make the translation as strait forward and OS X like as possible. I think that means that the translation probably shouldn't have to know about the XML at all, so just localizing the XML files doesn't seem to make sense.

Thanks,
Jesse
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: advice on localizing specific attributes from XML file
      • From: "Steve Shepard" <email@hidden>
  • Prev by Date: Re: NSArrayController (or NSObjectController) in Entity Mode
  • Next by Date: Re: ObjC BOOL and boolean c expressions
  • Previous by thread: Re: Waiting for a USB device to connect
  • Next by thread: Re: advice on localizing specific attributes from XML file
  • Index(es):
    • Date
    • Thread