views:

758

answers:

3

Ours is an open-source Mac application localized by volunteers. These volunteers will do their work on special localization builds of the software (with unstripped nibs), then send us the changes to integrate into the original xib and strings files.

The problem is that, while there is a way to integrate string changes without blowing away previous size changes, I can't see a way to integrate new string and size changes (as when we add or replace views).

The only way to do both that I can see is for localizers to work directly with the original xibs and send us diffs. That means they have to download the entire source code, not just a localizable version of the release, work in Xcode as well as IB, and either run the diff command themselves (per xib) or install and use Mercurial.

Is there any better way for a xib-based application?

+1  A: 

I confess that I'm not all that familiar with the process of localizing Mac apps. But I did run across a script that's part of the Three20 iPhone library that seems like it might be useful: diffstrings.py is a Python script that "compares your primary locale with all your other locales to help you determine which new strings need to be translated. It outputs XML files which can be translated, and then merged back into your strings files."

EDIT: As a companion to Wil Shipley's answer to this question, I'll add a link to a blog post he just wrote that goes into more detail about localization, and provides some of the tools that he's built to ease the process.

Sixten Otto
That sounds a lot like my own Localization Helper, right down to only working with strings files, not xibs/nibs.
Peter Hosey
A: 

Bear in mind that XIB files are merely XML files in an obscure format, so you can translate those easily enough, provided that you can find what strings there are there to translate in the first place. For example, here's the snippet that creates a button called Jenson:

<object class="NSButtonCell" key="NSCell" id="41219959">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Jenson</string>
...
</object>

So you can get that string translated and then substitute occurrences of it in the XIB with your translated value. In order to verify it's working as expected, you could change the language to use random keys instead (like BUTTON_TITLE) which will make it easier to spot when one's missing.

However, the positions/sizes of the items are fixed, so you can have titles that overflow the space given in a different language. That's one of the reasons why Macs have separate XIB files for every language, to allow adjustments to be made on a language-by-language basis, however difficult it is to maintain.

AlBlue
I know all of that. That's the context of the question: How to get not just string changes but also frame changes from the translated nibs that the localizers send us into our localized xibs.
Peter Hosey
+18  A: 

I strongly strongly STRONGLY recommend against frame changes in localizations. I know this runs counter to Apple's advice, but there are SO MANY problems with allowing frame changes - you end up with a billion edge cases.

Imagine you have 10 XIBs in your app, and you support 12 languages. You've got 120 different layouts to support, now. You just can't do this.

Change the strings, leave the views where they are. Make 'em bigger in ALL languages, if you need to. It sounds like this shouldn't work but it does. (I won three Apple Design Awards with an app that's localized in 10 or so languages this way.)

Specifics:

  • For radio and checkboxes, just let them extend far to the right, beyond the last English character. That also provides a nice big landing area for imprecise mousers.

  • For buttons, they should be wide anyhow, because it never looks good to have text cramped in the middle of the buttons.

  • For titles on tableview columns, you should autosize when you load 'em up, if needed.

  • For explanatory text, you should have some extra space to the right, and maybe an extra line. It just makes the English version of the XIB seem less cluttered. Sure, the Germans are going to see a slightly tighter XIB, but, hey, they're Germans -- they're probably used to that. There's probably even a German word for it. "Deutscheninterfakkenclutterlongen."

  • If a text field is centered, just add equal space on both sides. There's no reason not to.

I've combined this with scripts that suck all the strings out of my XIBs and put them in .strings files, and then dynamically put the strings back at run-time, so anyone can localize my app without any special tools. Just drop in a bunch of .strings files and run it!

-Wil Shipley

Wil Shipley
What about right-to-left languages, such as Hebrew and Arabic?
Peter Hosey
That's a good point... I kind of wonder what they do for checkboxes anyhow.One thing you could do is resize text boxes to be *smaller* if needed when the NIB loads and the localization doesn't require the whole space -- I started work on this but never finished it.
Wil Shipley
[I'll probably worry about it if I ever get any Hebrew or Arabic localizations -- sadly the hot Israeli girl I was dating dumped me.]
Wil Shipley
Maybe you should have had a Hebrew localization then!
jbrennan
And the complete blog post for reference:http://wilshipley.com/blog/2009/10/pimp-my-code-part-17-lost-in.html
0xced