Localization of text strings on iPhone: the easiest way

Locating text strings on iPhone is without a doubt one of the easiest things to handle when working on a game or application. Everything you need is already provided with the iPhone SDK.

However, since you have to use specific functions for localizable texts, you would be well inspired to learn about localization techniques for handling iPhone before you even start coding your application.

The process can be divided into a few simple steps:

1. Use NSLocalizedString while encoding

NSLocalizedString is a function that returns an NSString that contains, if possible, the translation of the text that you will give as the first argument, in the default language of the user, or the first language for which it can find a translation according to the preferences of the user. If it can’t find any text, it will only return the text you provided by default.

Example: NSString * text = NSLocalizedString (@ “Text to translate”, @ “Contextual comments”);

Put the string that you would like to see translated into the first NSString argument. You can use the second argument to (later) provide the translators who will work on your files with comments

and useful contextual information. If you are using things like ‘% d’ it is probably a good idea to use the comments part to explain to translators what they are seeing, even if it seems particularly simple to you. Translators are often confused when they see something that is not plain text.

2. Gather your strings

Now that you have finished coding your application, you will probably want to gather the strings that need translation and send them to your translators. Fortunately, this can be done automatically, so you won’t have to search everything yourself.

First, for each language you want to implement, create a corresponding folder named languagecode.lproj. For example en.lproj, fr.lproj, ja.lproj, etc.

Then open a Terminal window on your Mac and go to your project folder (if for some reason you are unfamiliar with command lines, a cd Documents / projectname will in most cases). Now suppose you used English for the NSLocalizedString arguments. All you have to do is type the following command:

genstrings /en.lproj /Classes/*.m

The command name is pretty self-explanatory: genstrings will generate strings, checking all source.m files in your Classes folder, looking for NSLocalizedString arguments, and putting them together in a file inside the /en.lproj directory. That file is called Localizable.strings, a simple text file that contains a sequence of lines like this:

/ * Comments you put in the second argument * /

“String you want to see translated” = “String translated”

Normally, the left and right strings should be identical for the language you developed the game for earlier. You may want to use an identification code for your strings, but I advise you to be careful as they will be displayed in case of problems. Then this one is ready to go.

3. Translate your files!

Now you can send that file to your translators and ask them to translate ONLY THE RIGHT PART. I am very serious about this. It is really a big unnecessary hassle to translate files with both columns, which makes the file unusable and waste your time. Make sure the name of the files you get is still Localizable.strings and put them in their respective .lproj folders (fr.lproj for French, etc.). There are a couple of tricks to make the process a little easier for translators, which helps you, the programmer, in the end. I will offer some advice in a later article.

4. Try and try a lot

A common mistake developers make is simply copying the translated files, checking a screen or two to make sure the correct language is displayed, and then assuming the game is ready. It probably isn’t! Before launching your game, ask a native speaker of each language to review your application thoroughly and make sure there are no issues such as:

– Wrong or missing translations

– Texts that do not make sense in context or that are misleading

– Text overflows (you’d be surprised how long some short English words can last in, say, German)

– Major display bugs and problems: It is very easy to remove a “or alter a% s, which can cause major problems in your application.

The last three reasons in particular can cause your game to be rejected during submission, so when testing your game take the process seriously for ALL languages, making sure to use native speakers.

Overall, the iPhone SDK comes with everything you need to do simple text localization. If you are unfamiliar with localization techniques and are looking for an easy and accessible process, this option is the perfect option you could wait for.

Discover How YOU TOO Can Easily be a Recording Gamy Tester Deed Postpaid To Movableness Recording Games at Internal!: Click Here

Comentarios

Entradas populares