Re: Localized strings in reverse
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.