Localizing Nibs

Localizing Nib/Xib files is tedious and error prone. You want to reduce the manual edit to a minimum. (Basically, just the traslation.) Oversights and other weirdness may still happen though. This is the process I follow.

  1. Save Nib in en.lproj folder.
  2. In Xcode, select the Nib, open the Utilities pane and select the first tab (View > Utilities > File Inspector) and add a localization (e.g. Italian). Xcode will create a new file in the right location (it.lproj folder).
  3. From Terminal:
# extract all strings from original nib file
$ ibtool --generate-strings-file text.strings en.lproj/MyNib.xib 

# open file in Xcode, translate all the strings and save
$ open text.strings

# create a new nib exactly like the original but with the localized strings
$ ibtool --strings-file text.strings --write it.lproj/MyNib.xib en.lproj/MyNib.xib

Finally, Run the app. If the localized Nib is not displayed, it’s because iOS is holding a cache of the Nib file. Remove the app from the simulator or the device and reinstall it. Now it should show the new localized Nib.

Advertisements

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