Step 1: Create 2 directories called en.lproj (English) and it.lproj (Italian)
Step 2: Add new string file by going to File -> New File -> Other -> Strings File, name the file as "Localizable.strings" and place it in en.lproj.
Step 3: Repeat step 2, this time saving "Localizable.strings" inside it.lproj.
Step 4: Add the following lines to the strings files...
"WelcomeKey" = "Welcome!!!"; // put into english version
"WelcomeKey" = "Benvenuto!!!";
// put into italian version
Step 5: To grab WelcomeKey you just do: NSLocalizedString(@"WelcomeKey", @"") like so:
NSLog(@"Welcome Text: %@", NSLocalizedString(@"WelcomeKey", @""));
That's all there is to it... Here are some of Apple's conventional language codes:
English: en
Japanese: ja
French: fr
Deutsch: de
Netherlands: nl
Italian: it
Spanish: es
Portugues: pt
Korean: ko
Simplified Chinese: zh-Hans
Traditional Chinese: zh-Hant
The full list can be accessed through the following call:
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
// print each NSString in languages
No comments:
Post a Comment