In my folder, where my project was located, I created 3 directories. For each language 1:
- en.lproj : This is where the English localization files go
- nl.lproj : This is where the Dutch localizations files go
- de.lproj : This is where the German localization files go
CREATED STRINGS FILES
In each of those directories I created 2 strings files, I did this by right-clicking the resources folder in Xcode, select Add -> New File. Then click the Resourcetag under Mac OS X and select Strings file.
When the New File dialog comes up, make sure you select the right location. You want to create 2 files per language directory you created with the step mentioned above. Name the files:
- InfoPlist.strings : This file I created to be able to localize my application name
- Localizable.strings : This file contains all the text my application is showing, in the appropriate language
Mind the capitalization, this is very important because we are running on a case sensitive file system.
FILL YOUR LOCALIZABLE.STRING FILE
What you need to do now is maybe a little bit of hassle, but you need to copy all the string you used in your application to this application and give them keys by which you can identify them. With keys I mean unique keys.
For example, my localization file in the directory nl.lproj looked a bit like this:
"Add new product" = "Voeg product toe";
While my localization file in the de.lproj looked like this:
"Add new product" = "Neue produkt";
I think you get the point.
ACTUALLY DISPLAY THE STRINGS
Now, after you spend hours filling your localization files and translating it to every language known to man you want to actually display some text in your application. Well that is pretty easy.
- (void) doSomeStuff
{
myLabel.text = NSLocalizedString(@"Add new product", @"");
}
Whenever a language file for the users language could not be found, it will default back to the key and show that instead. So make sure your keys also say what you want your button/label/etc to say. That’s it! There isn’t more to it than that.
BUT WHAT ABOUT MY APPLICATION NAME?
I almost forgot. Remember that you created 2 files for each language? Well, just put this line in your InfoPlist.strings files (ofcourse with the translated application names).
CFBundleDisplayName = "My App Name";
Hope this helps you out.