One thing that makes the iPhone so much fun (development-wise) is the ease of localization integration. Unlike website (or most software) development, XCode makes it easy to create and organize all text within an application, send it off to be localized, and then re-integrate and test it.
Setting Up and Preparing
Apple has made it incredibly easy to develop localized applications. All strings that are to be localized should simply be passed an NSLocalizedString instead of an NSString.
myButton.text = NSString (@"Click Here!");
myButton.text = NSLocalizedString (@"Click Here!", @"Label for button");
The NSLocalizedString function takes two parameters: the default text, and a comment describing how the text is used (this is good to help translators figure out the context of the text).
Once the application is ready for translation (basically, fully tested and ready to submit to the App Store in your local language) you can execute a simple script that will pull all of the NSLocalizedStrings out of your class files, and put them in a text file, which can then be translated and replaced.
To do this:
- Open Terminal
- change directories to your project folder
- create a folder called en.lproj:
- Generate the string file:
genstrings -o en.lproj Classes/*.m
(You will need to drag the en.lproj folder into your XCode project as well)
This will create a text file called Localizable.strings within the en.lproj folder, which contains all the strings with comments, looking something like:
/* Label for button */ "Click Here!" = "Click Here!";
To localize this into other languages, you’ll need to create additional language files. Make sure you name them based on the two letter ISO country code (de for German, fr for French, ja for Japanese, etc.)
You would then replace the text in those files with localized strings. For example:
/* Label for button */ "Click Here!" = "Klicken Sie hier!";
When submitting all the text to be translated, DON’T FORGET to write the marketing copy that goes into the App description for the App Store. It helps to have this pre-written before you submit the text to be localized, so you don’t have to keep going back and adding changes to things (fortunately, when I just did it, I had had that copy written well in advance).
There are a number of translation services, and most are pretty good. Almost all of them outsource to third party translators *which is what you want* as those people are usually in their respective countries and will give you the most accurate representation that you could have from the standpoint of that culture and language.
The site I prefer is icanlocalize.com. In the past, I had used click2translate.com (a website that’s owned by SDL International, which is a well respected and very well established translation firm). However, I took a chance with the icanlocalize.com site because they seemed to have a knowledge of working with iPhone application localization — to the point where they had “how to’s” on setting up NSLocalizedStrings, working with Interface Builder, etc.
They have a system for uploading a strings file, which parses it and sets up each string in their database, as well as gives an estimate of cost for localization (in my case, US$0.07 per word, or about $35 for each language). I submitted my app in French (for Canada as well as France), Spanish, German, Italian, Japanese, and Dutch.
French and Spanish are definite requirements for any localization project in the Americas (because of Canada and all of South America), and I have received so many downloads of apps from Japan that I considered Japanese an essential language.
I chose the other languages (German, Italian, and Dutch) because the App Store supported them. Probably not the best reason, but Apple had to have a reason for supporting those languages, and I’m looking forward to seeing if there’s a correlation in number of downloads.
There are a few ways that images can be localized. One trick that a friend of mine (Justin Leger) came up with:
When using imageNamed, you pass a string with the name of the image. If you need a localized file (an image with localized text), simply send an NSLocalizedString with a name for the image.
UIImage *img = [UIImage imageNamed:NSLocalizedString (@"logo_en.png", @"Logo Image")];
This way, it will default to using logo_en.png, but different language files can use other logos if you have them. For example, you can change the French file to have:
/* Logo Image */ "logo_en.png" = "logo_fr.png";
…but the Japanese file could simply default to the English logo (for example, if you didn’t have a Japanese-specific logo).
Localizing the iPhone Application Name
I prefer not to translate an application name (typically, I prefer to create a specific brand name, which would not necessarily be translatable. For example, “twitter” would be “twitter” no matter what language the rest of the application is in.)
However, for cases where this is necessary, you can create an InfoPlist.strings file in each of the language folders.
In XCode, create a new strings file. Go to File -> New File -> Other (under Mac OS X) -> Strings file. Call it InfoPlist.strings, and save it in the appropriate .lproj folder.
Then, just create a text entry such as:
CFBundleDisplayName = "appName";
(But replace “appName” with the translated name of the application).
Notes on Colloquialisms (Slang)
Because I was translating a game, I had a heavy use of slang. I did not want my jargon to be translated literally, nor did I want a technical translation, which would have taken the authenticity out of the localization.
For example, if I had had something like:
“Dude! That was sick!”
I did *not* want a literal translation (which would make no sense) — something like “Friend! That has an illness!”
Nor did I want a technical translation (as if I literally translated the phrase based on what the intent is, using beginner words in the destination language) — something like “Sir, that was good.”
What I wanted, was something that would have the spirit of my original language, but have the proper jargon for the destination language.
What I was trying to achieve was a sense of authenticity for that language — something where someone could run the app in their native language and think “well, this must have been designed in *my* language, and just translated into all the other ones”.
To me, this is what separates “translation” from “localization”.
In order to communicate what I wanted, this is what I sent in the project description:
This is a game for the iPhone. There is a lot of “slang” text (in the instructions) that would not make sense/be culturally translatable in another language — what I need is for someone to understand what it is trying to communicate, and write a replacement that would make sense for their language and culture. I have created a PDF at http://pushplay.net/putterball/Putterball_Localization.pdf which should make this easier to understand.
When I refer to colloquialisms, I’m not worried about the English slang that I used — I’d just like to make sure there is proper native slang in the translations. For example, “please make sure you click on the appropriate symbol” is kind of boring, but “hit that button, yo” is a more playful (yet untranslatable into another language) way of saying the same thing…
In other words, I would like the native language you create to have colloquialisms pertinent to a native speaker of your language. For example, in French the phrase “mon petit chou” would be used to express a term of endearment — and is 100% correct — even though literally translated into English it would read “my little cabbage”. If, instead, the obvious “mon amour” is used, the translation wouldn’t have the feeling of authenticity that I’m trying to achieve. (Please excuse my poor French. )
What was fantastic about the people who are working with icanlocalize really “got it”. They completely understood what I was trying to do. For example, here was some of the feedback I got from Yuko, the Japanese translator:
I kept in mind the end-user(game player) experience as a point of reference, rather than technical or direct tranlation Japanese, as you noted in your pdf. I would assume that the end users are actually golf fanatics in real life as well; thus, the levels of difficulty has been translated as “beginner, amateur, and professional”. I have also translated “you can sink any putt” as “you can one-put any green”(=which is the lingo Japanese golf fanatics use).
Localizing an app for the iPhone is easy, and a lot of fun — but does take some forethought. Once I got the translation strings back, I did have to go back and resize some UILabels (to make sure the text fit in all languages). For the most part, everything worked pretty smoothly, but you will need to thoroughly test your application in every language.