Posted by: bearc0025 | November 13, 2009

Localize – Localization an iPhone application

There are several steps, but none are monumental:

1. In the code, you need to call NSLocalizedString:
NSString *NSLocalizedString(NSString *key, NSString *comment);
See NSLocalizedString

“The second parameter is a comment that indicates how the string is used and therefore provides additional context to the translator.”

reference page

So you call it for your strings like:

NSString *translatedString = NSLocalizedString(@"City", @"label for textfield");

2. Create the strings files:

Read Using the Genstrings Tool to Create Strings Files, but basically you’re going to run:
genstrings -o en.lproj *.m
(NOTE: en.lproj as a dir must already exist)

Also read the section titled “Detecting Nonlocalizable Strings” which explains the NSShowNonLocalizedStrings option for detecting non-localized strings (e.g., executing an app like /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSShowNonLocalizedStrings YES)

In the strings file you just created, there are entries like this:

/* label for textfield */
"City" = "City";

Make a copy of that file in a new language dir (e.g., de.lproj for German) and translate the values as such:

/* label for textfield */
"City" = "Ville";

Tutorial for iPhone | Localized your iPhone application | Localization of your iPhone application | Different language for your iPhone applciation | iPhone Diary | Localization

Advertisements

Responses

  1. crowdin.net is nice solution for translation of .strings files

  2. If you’re involved with software localization, you might want to check out this new localization tool my team recently developed- http://poeditor.com/ It also works with .strings files.


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

Categories

%d bloggers like this: