Re: Localization and PB
Re: Localization and PB
- Subject: Re: Localization and PB
- From: sinclair44 <email@hidden>
- Date: Sun, 23 Feb 2003 14:52:02 -0500
On 2/23/03 2:23 PM, "Jesus De Meyer" <email@hidden> wrote:
>
Wow, nice, now I have a menuitem hardcoded in English, but I want it so that
>
the text gets translated with the current language. How is this done? Do I
>
need to set a key in Localizable.strings and then do:
>
>
NSString *localizedMenuItemTitle = [mainBundle
>
localizedStringForKey:@"menuItemKey" value:@"" table:@""];
I'm not entirely sure what you're asking. You can localize a nib file; the
languages are kept separate. No code is needed to do this.
For hard coded strings, used like this, a little more work is needed:
[someTextField setStringValue:@"English String"];
Create a blank file named "Localizable.strings" and get info on it. Select
"Make localizable" from the drop down, and then create a new variant. Now,
edit Localizable.strings like this in the English variant:
someTextFieldValue = "English String";
And like this in the, for example, German variant:
someTextFieldValue = "German String";
The above line of code, setting the string value of someTextField, needs to
be changed as follows:
[someTextField setStringValue:NSLocalizedString(@"someTextFieldValue",
nil)];
(Repeat, adding more string/value pairs to Localizable.strings and getting
them via NSLocalizedString().)
NSLocalizedString is a macro that calls [NSBundle mainBundle] for the
localized string, and the runtime handles the rest. If you have any more
questions, either I or someone else on the list should be able to answer.
--
-- sinclair44
[self becomeWorldDictator];
- (void)becomeWorldDictator
{
[[world currentLeaders] assassinate];
[[world citizens] terrorize];
[world setCurrentLeaders:[NSArray arrayWithObject:self]];
}
_______________________________________________
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.