• 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
Re: Localized strings in reverse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Localized strings in reverse


  • Subject: Re: Localized strings in reverse
  • From: Shawn Erickson <email@hidden>
  • Date: Tue, 2 Jul 2002 10:46:42 -0700

[no need to cross post... cocoa issues are best answered on cocoa-dev]

On Tuesday, July 2, 2002, at 10:23 AM, Carl Jochen Norum wrote:

Is there any way for me to get a localized string's key? Here's an (artificial)
example:

I have a pop-up button whose labels are provided via NSLocalizedString(a, nil).

Now, based on what the label is on the button, I want to load an NSImage by:

NSImage *image = [NSImage imageNamed:
[[button titleOfSelectedItem] stringByAppendingString:@".pdf"]];

This will only work if the localized string matches the filename. What if I want
to have only one file, and allow multiple localizations access to it?

I think the easiest way would be to save the image under the localization key's
name, and then restore that key at runtime from the localized string in the Pop
Up button.

Anybody?

You can figure out which item was pressed by using the tag associated with each item or by using the items index. This way you can avoid localization issues in your action.

If you only have one file per item and it is always named the same you could simply load the file when the pop-up button is released regardless of the selected items name. If the file's name changes and the item's name does not necessarily reflect the true file's name you can easily enhance you action logic to deal with that (using defaults to store the file name, an enhanced switch statement based on some criteria, etc.).

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: TextView and attachments
  • Next by Date: TIFFRepresentationUsingCompression not working as it should
  • Previous by thread: Re: [newbie] Hot Key
  • Next by thread: Re: Localized strings in reverse
  • Index(es):
    • Date
    • Thread