Re: Which is correct? (itemWithTitle & NSlocalizedString)
Re: Which is correct? (itemWithTitle & NSlocalizedString)
- Subject: Re: Which is correct? (itemWithTitle & NSlocalizedString)
- From: Greg Titus <email@hidden>
- Date: Sun, 3 Sep 2006 07:43:15 -0700
On Sep 3, 2006, at 7:35 AM, Keith Blount wrote:
Hello,
A really simple question that I'm not sure about:
When getting a menu item using -itemWithTitle:, which
will correctly work for localized .nib files?
item = [menu itemWithTitle:@"Some Title"];
or
item = [menu itemWithTitle:NSLocalizedString(@"Some
Title",nil)];
I haven't localized yet but would like to make sure my
app doesn't need to much recoding when I do...
Thanks in advance - sorry if this is a silly quesiton.
Keith
Hi Keith,
Not a silly question at all. Yes, when you are running in another
language, the titles will all be different, so -itemWithTitle: will
need to be called with the localized title and not the English title.
But I would advise not using -itemWithTitle: at all, because if you
do this, that means you will have to make sure that the localized nib
and the localized string file exactly matches for every language.
Better to either add a tag to the item in the nib and use -
itemWithTag:, or even better, [menu itemAtIndex:[menu
indexOfItemWithTarget:nil andAction:@selector(someAction:)]]. That
way you will be looking up the item based on something that will be
remaining the same in all of the localized nibs and you won't have to
worry about localization errors potentially breaking your code.
Hope this helps,
- Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden