Re: Which is correct? (itemWithTitle & NSlocalizedString)
Re: Which is correct? (itemWithTitle & NSlocalizedString)
- Subject: Re: Which is correct? (itemWithTitle & NSlocalizedString)
- From: Keith Blount <email@hidden>
- Date: Sun, 3 Sep 2006 08:22:03 -0700 (PDT)
Many thanks for your reply, Greg, much appreciated. So
far I have been using NSLocalizedString() in all of my
checks, so it is good to hear that this is necessary,
even if I do have to be careful.
Wherever I can, I use tags and itemWithTag:, but this
isn't possible in some situations; in some situations
I cannot use itemWithTag: or
indexOfItemWithTarget:andAction:, in fact. For
instance, some of my menu items have the same target
and the same action, but different tags which are used
by the action to determine what to do. And
occasionally in these menus there may be other items
with the same tags that determine different actions
(hope that makes sense). In these circumstances, it
seems the only way of determining the item is via the
title...
Also, what about determining an NSMenu rather than a
menu item? I use all of this in -menuNeedsUpdate:, so
to determine the menu that is currently calling this
delegate method I use if ([[menu title]
isEqualToString:NSLocalizedString(@"Some
Menu",nil)])... Given that NSMenus don't allow tags,
is this the only (and best) way to determine the menu?
Many thanks again,
Keith
--- Greg Titus <email@hidden> wrote:
>
> 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 You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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