Internationalization of my iPhone app

How does the user change the language of the application?

It looks like he can only change the language of the entire iPhone (Settings -> General -> International -> Language).

After the change, an app internationalized for that language will respond in it.

How does the user change the language of the application? – take two –

It turns out that an application can give the user a choice among languages that it supports,

say “en”, “fr”, “de”, “jp”.

When the user selects one of these codes (in the app’s own Select Language menu), the app should do

 [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:languageCode2LetterString, nil] forKey:@"AppleLanguages"];

and instruct the user to stop and to restart the application.

The application will now come up with the newly selected language.

How do I set up an Xcode project for internationalization ?

  • replace strings in the program like
label.text = @"Hello world.";

by

label.text = NSLocalizedString(@"Hello world.",
@"This is a comment about my greeting.");
  • add directories en.lproj, fr.lproj, de.lproj e.t.c.
  • run : genstrings -o en.lproj Classes/*.m
  • add the generated en.lproj/Localizable.strings to Xcode project resources (save as UTF-16!)
  • copy en.lproj/Localizable.strings to fr.lproj/Localizable.strings and edit it to provide translations
  • add fr.lproj/Localizable.strings to project Resources
  • build
  • test

OK, there is more to it but this is a start.

Advertisements

One thought on “Internationalization of my iPhone app

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s