Panic on American ApparelCar in Snow, Part 5Car in Snow, Part 4Car in Snow, Part 3

fill the void

Posted
15 April 2009 @ 7pm

Tagged
development

3 Comments

ibtool: Localization Made Easier

When I wrote the first post on localization, I hadn’t discovered the full power of ibtool or the need for all that power. I figured out how to re-generate the localized XIBs from an English version and a .strings file. But soon, I needed to incrementally incorporate changes from the English XIBs, without blowing away the previous localized XIBs. The most common reason is element sizing. Text translated from English to languages like Spanish dramatically increases in length, but the UI elements in the English version are fit to the English text. Luckily, ibtool solves this problem as well.

Apple’s documentation has a great explanation for solving this problem, summed up in the code below.

ibtool --previous-file ./old/Resources/en.lproj/MyNib.nib
       --incremental-file ./old/Resources/fr.lproj/MyNib.nib
       --strings-file ./new/Resources/fr.lproj/French_2.0.strings
       --localize-incremental
       --write ./new/Resources/fr.lproj/MyNib.nib
       ./new/Resources/en.lproj/MyNib.nib

The ruby script from the earlier post is a little more complicated because I need multiple versions of the English XIB. The new process involves a bit of manual work, unless I incorporate SVN into it. However, it’s worth it. ibtool lets me push incremental updates into localized XIBs without losing past changes to them.

I considered implementing a more dynamic interface, where a custom NSView subclass governed how the elements were laid out in any given view. Sofa, the talented group behind Checkout, Versions, and Disco, went that direction according to an Apple interview: “We generate all of Checkout’s localization resources at build-time and dynamically resize views to fit oversized strings.” That approach was tempting, but I wasn’t sure how to deal with the many variants of views I had.

One issue I encountered before I found genstrings was not having translations for all the strings I called in NSLocalizedString. Apple has a nice argument to add to an application to point these out: NSShowNonLocalizedStrings. So, to look for non-localized strings in TextEdit, I would type:

/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSShowNonLocalizedStrings YES

Apple has more information about this trick.

Resources


3 Comments

Posted by
Tips: Localization at Under The Bridge
6 May 2009 @ 11am

[...] ibtool: Localization Made Easier [...]



Posted by
fill the void – ibtool Caveats
10 August 2009 @ 10pm

[...] be used to automate localization tasks: generating a .strings file, localizing an English XIB, and incrementally updating a localized XIB. It’s a fantastic tool, included in the Xcode development installation, and works well for [...]


Leave a Comment