Localizing Mac OS X strings files using open source PO editors

Do you hve a nice shiny Mac or iPhone app that you want to translate? Now you can easily manage the localisation of Mac OS X .strings files with translators using common open source PO editing tools.

I'll post a little later about using Pootle to allow you to do web-based community localisation of the same strings files.

Firefox Home become the motivator

I've really wanted to write this for a while, in fact a bug has been lurking about this very issue for some time now. But it was the release of Mozilla's Firefox Home for the iPhone that really got me going.

Firefox Home: Search, bookmarks and tabs

I just knew that we could make it easy to localise not just Firefox Home but any iPhone app.

But why don't you just use a text editor?

Good question. Why not just use a text editor? Well you can do that. But as I always like to say you wouldn't ask a vim user to use Emacs now would you? Or a better example, you wouldn't swap your favourite IDE for Notepad. Of course you wouldn't. So why do you ask a translator to swap their high performance translation tool for a beat up old text editor? Do you hate translators that much that you'd inflict on them something that you'd never do to yourself?

There are good strings files editors why not use those? Two reasons. Firstly, we want translators to use the tools that they are familiar with and in the case of open source localisation it's most likely an open source PO editing tool. Secondly, for web translation we want to be able to do a few things the strings files just can't do which we get when we convert the file to PO.

What are the benefits of converting to PO

  1. We hide the encoding, users don't need to worry about getting the file into UTF-16
  2. We manage escaping, we hide that from the user and they don't need to learn anything about .strings escaping
  3. The output strings files look like the input, we preserve layout and comments so you can get cleaner diffs with the original
  4. We don't break files, if we do its a bug. For a programmer this is great as you are almost certain that the files you have won't break a build. You could even pull in the latest translations and be confident that they aren't broken
  5. Partial translations can be used in your application while testing
  6. Translators get to use their familiar PO editing: Virtaal, Poedit or Lokalize
  7. You are able to do community based web localisation using Pootle

What are strings files

Strings files are simple key value files that look like this:

/* Comment */
"key" = "value";

"Save As..." = "Stoor as...";

What is the translation process now with PO files?

First we convert .strings to PO files.

Note: prop2po strings support is not in a released version of the Translate Toolkit. But you can use these instruction to run from a checkout.

prop2po -P English.strings English.string.pot

Send English.strings.pot to all of your translations. They can rename this to their language e.g. German.strings.po and begin translating in any PO editing tool.

Converting back is just as simple.

po2prop -t English.strings German.strings.po German.strings

You now have a German.strings file that can be used in your application. An added benefit is that even if the German is only 50% translated we can still convert back for testing. If you haven't translated something then we'll just insert the English into German.strings.

When you update the English.strings it's a simple matter of sending your translators the new POT files and they can update their old PO files using their PO editor. Compare that to anyone using strings files in an editor who would need to perform a diff and manually check for changes, why do that if you can simply get the translator to update the file and let their PO tool show them what needs translating.

You can hide translators from the po2prop and prop2po step making it a very simple matter of publishing a POT file for translators to keep up-to-date.

However, we can make it even easier by using a web based translation tool like Pootle. In this case the translators don't even need to do the updating, you can do that for them.

As I said I'll be making another blog post about setting up a strings project on Pootle.