Monday, November 22, 2010

Best Practice Localization/Internationalization Xcode iPhone project - NIB files

This article describes how to setup localization on your NIB files (.xib files).

I wrote another article about how to setup localization for your Strings in the class files (.m files). I recommend reading the other article to get a better understanding of the whole localization process of iPhone apps with Xcode.

Create localized NIB files

First you should bring the according file into a status that can be called complete. You can afterwards still change the file but it makes sense to edit the other language views only once aat the end.

To create the localizations perform the following steps:
1. Right-click on the according .xib file in the Resource folder and select "Get Info".
2. In the window under "General" click "Make file Localizable".
3. Then again under "General" repeat "Add Localization" for all languages you want to support.

The result in the Groups & Files view of Xcode should look like below.


Change the text of labels, buttons etc. for the according language of the .NIB file


Now that you have all the language versions under the NIB file, you can open each separately and change button and label text for the language.
Now Build and Run you App on the iPhone simulator. When you change the language of the iPhone to one of the languages provided in your app the buttons and labels will show the right language.

Troubleshooting: I changed the language in the iPhone but the old NIB file content is displayed


Try to:

1. Clean the Target.
2. Remove the app from the iPhone emulator. (Hold left mouse button down on any app icon until the icons wiggle. Click x for delete. Click iPhone Home button.)
3. Build and Run again.

Sometimes deleting the build folder could also help.

0 comments:

Post a Comment