Skip to content

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:
[sourcecode lang=”cpp”]
NSString *translatedString = NSLocalizedString(@"City", @"label for textfield");
[/sourcecode]

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:

[sourcecode lang=”cpp”]
/* label for textfield */
"City" = "City";
[/sourcecode]

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

[sourcecode lang=”cpp”]
/* label for textfield */
"City" = "Ville";
[/sourcecode]

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

0 thoughts on “Localize – Localization an iPhone application”

  1. 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.