views:

212

answers:

1

As part of an i18n project, I need to extract strings from a NIB file programmatically. This can be done quite easily with ibtool, of course. But this is a cross-platform product, of which the NIB is only part. It would be nice if we didn't have to lock string extraction to a particular machine, or have to kludge together catalog-merge scripts.

So I realize it's a long shot, since the demand for this is probably quite low, but are there any open-source alternatives to ibtool? Is there any documentation on the NIB format reliable enough to write a parser from?

+1  A: 

If you use XIBs, then they are simple XML files. Just look for string elements that have the key NSContents. If you're familiar with XML parsing, it shouldn't take long to reverse engineer --export-strings-file in almost any language.

If you can't move to XIBs, you can read the keyedobjects.nib, which is a binary plist. One portable reader is the Perl implementation plutil.pl. You can also look at Apple's open source code to handle them in CFBinaryPlist.c. If you need to go this way, look at OpenCFLite. Reading and writing Plists is a key reason people use the portable Core Foundation.

Rob Napier
I didn't know about XIBs; exactly what I was looking for, Thanks!
DNS