views:

249

answers:

4

Hi Guys

I am writing a app which has about 10 nib files for conveying different UI messages and for taking user input. I want to know how to localize these messages that appear on my custom sheets. Is there any way i can have a single file with generic strings and depending on language it replaces the generic string with string in that particular language. also i want to know how to load dynamic strings into messages in custom sheets like file names or the number of files selected etc.

i have taken a look at ibtool but doesnt it duplicate the nib files by creating .lproj files for different languages? doing this simply makes the size of my app huge.

Thanks

+2  A: 

Standard practice is to have a nib for each language.

Your nibs shouldn't be more than 50-100 KB unless they're storing some uncompressed bitmap images, in which case you should load those images in code. Some components, like NSPathControl, will store uncompressed icons in the nib and add a few MB to the nib.

If you have a large .xib file open it in TextEdit and it should be obvious what's taking up all the space.

Darren
thanks Darren. I agree that they take around 100 kb but imagine about 15 nib files in 10 languages which means 15 * 10 * 100 kb right which is very huge right
King
In a typical app I'd expect most compiled nibs to be small (1 kb) with one or two that are larger (25 kb). As they say, don't spend time optimizing something that doesn't need to be optimized. I think most users are comfortable with an app that a few MB in size.In XCode it's very easy to set up your nibs for localization. If, after that, you decide your app is too large you can always un-localize some large NIBs and instead set the text labels programmatically.
Darren
Thanks Darren. Typically all my nibs are around 30 kb. I am having an image in .png formay in each of them. Is there any way i can compress my nibs?
King
King, are your NIBs NIB 3.x format? If so, if you build on Snow Leopard, they'll be stripped at build time, and will become much smaller. If your working with Leopard, switching to XIBs will also produce stripped NIBs at build time, and they'll also be very small.
Jon Hess
+1  A: 

In addition to what Darren already posted, I would like to note that if you know most of your users are going to use English (or whatever the overwhelmingly most common language is), many developers will offer an English-only download that doesn't contain the nibs for other languages (thus reducing app size), and then also provide a multilingual download if desired.

Also, if you're programmatically generated UI elements, you'll want to take a look at the information for Localizable.strings, which is a text file containing translations for strings used programatically.

mipadi
+1  A: 

At a Boston cocoa-heads meeting a while ago, we discussed this topic and came to a consensus that where two decent approaches.

1 - The first is it either use IBTool or manually make separate nibs.

2 - Gain programatic access to your labels and change the text programatically. Mipadi mentions Localizable.strings as being useful. To gain programatic access, you can either wire-up each label through IB, or you could do some king of walk-the-nib magic and find all of the labels (exercise left to the reader).

Pick whichever method fits your particular app.

Hope this helps,

JJ

This question might help: IPhone localization: Is it possible to translate nib files...

JJ Rohrer