App L10N

flags

January 8th, 201210:29 pm


Negrita - L'uomo sogna di volare


1


http://developer.android.com/g...

Why localizing apps?

The app localization (L10N) is one of the most important features that an application must have for be more desirable by users. An application localized only in Swedish can be fine if this is in the interests only of a Swedish public. And vice versa an app localized only in English can be fine only if it’s a little application, that brings to users only a single and simple functionality.

So if you want to spread your application over the global market, initially you have to find what will be your public, and after choose some other localization (English is a must).

Different languages

When we write Android apps, if we wants to display some texts we use values pre-written as String in the app resources (if you do not have this habit, you have to start this way), so for example in the folder res/values we have in the string.xml file something like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="tale">The quick brown fox jumps over the lazy dog</string>
    <string name="greeting">Hello</string>
</resources>

So for example, if we want to make a localization of the same application in Italian (my language), we have simply to create another folder res/values-it (it is the two chars language code for Italian) with inside the same file strings.xml with the values translated. So we have:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="tale">La rapida volpe marrone salta sul cane pigro</string>
    <string name="greeting">Ciao</string>
</resources>

This procedure can be done for any folder under res, so we can have drawable-it, attrs-it, etc.

Different regions

The L10N isn’t applied only for different languages, but also for different regions, and the procedure for doing that is the same than the previous one. For example, if we want to localize the same application in French language but in Canadian region we have to create the folder res/values-fr-rCA where rCA mean region Canada. Into this folder we can create the strings.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="tale">Le renard brun rapide saute par dessus le chien paresseux</string>
    <string name="greeting">Allo</string>
</resources>

Best way for strings

A useful way to localize strings that includes some variables is to write strings with markers for a formatted string: for example if we want to localize “When will John explode?” where John and explode are the variables, we can write into strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="phrase">When will %1$s %2$s?</string>
</resources>

At the time of usage in Java we can compile the string as follows:

String.format(getResources().getString(R.string.phrase), nameVar, verbVar)

I recommend to use this method because translating strings, the sorting of words could change, and because is more simple making only one string resource for sentence, alternatively infact we have to make more than one string resource for sentence.

One Comment on “App L10N”


  • What you wrote is indeed very important. I recommend https://poeditor.com/, a very useful localization tool that works great with strings, xml, resx, po and xls files.

    Alex B
    posted on 1st of March, 2013 at 10:47 am

Leave a comment


Your name*

Your email*

Your website

Your comment*