Quantcast
:: PSD Help Line :: » Localize Your Android Apps
UXDE dot Net Wordpress Themes

Localize Your Android Apps

in Apps / No Comments

Thinking about localizing your android app, well it is without a doubt a great way to popularize your app. Localization is one of the fastest growing trends in the app world today.

Localization is a process to provide resources for your app in accordance with the language setting of the device. The need to provide support of local language on the app is due to the fact that most users prefer reading and communicating in their local language.

Before you jump into this localizing wagon make sure what you want from your app. You want to target only the local audience or global audience as well?

Localizing your app is only beneficial if you’re targeting different regions with variety of languages. In order to appeal to more-and-more users, your app should support texts, currency, audio files, numbers, and graphics according to the locales.

If you want to make your android app global, you need to support local languages. For this you require resource files that are placed in the subdirectories of “res” folder. An additional directory is created inside “res/” which enables you to use a resource in a particular locale. Inside this directory, include a hyphen along with an ‘ISO 639-1 language codes’ at the end of the directory name. After this you can add two optional letters ‘ISO 3166-1-alpha-2 region code’ (preceded by ‘r’).

The inclusion of region qualifier helps in hitting the target resource more effectively. For instance, use ‘-es-rES’ for Espana (Spanish spoken in Spain) and ‘-es-rUS’ for Estados Unidos (Spanish spoken in Latin America), instead of ‘-es’ the language qualifier for Spanish.

Now, when the user runs the app and the device’s language matches the language you have specified, the language resources are loaded.

MyApp/
src/
MainActivity.java
res/
drawable/
background.png
drawable-fr/
background.png
layout/
activity_main.xml
values/
strings.xml
values-fr/
strings.xml

The above code demonstrates an app supporting English, as a default language, and French as well. Also, the app has variety of “strings” along with background images for both English and French locales while sharing the same layout. The resource file with “-en” extension is not required here as English is the default language supported by the app.

For any directory allowed in the “res/”, you can provide language specific directories. The subdirectory names are tied to the Android build system and you should not specify them, because the resources included within the subdirectory will be ignored while the app delivers flawless functionality.

Moreover, save the resources in the “res” subdirectory as saving them in the root directory will cause build errors.

Default Resources

Default resources are necessary in every app. These resources can be found in the unqualified resource directories “drawable/” and “values/”. If your app doesn’t have the resource that matches device’s configuration and the default resource is also missing, the app will crash.

MyApp/
src/
MainActivity.java
res/
drawable-en/
background.png
drawable-fr/
background.png
layout/
activity_main.xml
values-en/
strings.xml
values-fr/
strings.xml

We have made slight changes in the previous example, and added the English qualifier to the files meant for English locales. This is not a good idea, as the app might crash if it runs on a device where there’s no support for the locale language.

Testing the Default Resources

Test all the default resources so as to ensure these are available in the default files. It can be done easily by changing the locale of your device to a locale that isn’t supported by you app. If you get an error message along with a Force Close button when you run the app, it means the app is searching for a resource that is missing from the default subdirectory.

Points to Remember

• If your app is using custom fonts, then you need to have backup option for foreign characters not supported by the font-family.

• Remember that word length varies with languages; this leads to variation in sentence length too. Moreover, few languages read from left to right and only translating string literals might not be enough for localizing your app. You might want to have different layouts for languages that require different display style. But, it will not be easy to maintain such an app.

• Avoid creating unnecessary resource files. Share the common resources. For example you might not want to translate the app title. Henceforth, keep these types of shared resources in the default directory instead of copying them to specific directories.

• Don’t make the mistake of hard-coding the resources. Use “R.string” to access strings in “strings.xml” file instead of string literals. Similarly use “R.drawable” and not image paths. These small things make maintenance and localization of app a lot easier with less glitch.

• Android system is equipped to handle localization, but you might be tempted to change little code in compliance with the users’ locale. The “context” object is used to get the locale.
String locale = context.getResources().getConfiguration().locale.getDisplayName();

Bottom Line

Localizing your app might help you to mark strong presence more in countries where English (app’s default language) is not the first language. Therefore, you should undertake the research about localizing your app and the languages you want your app to support.

I am a creative blogger and professional writer. Web Design, Web Development, SEO, Social Media, WordPress are some of my lively interests. I loves to share my knowledge, insight and best practices I've learned so far.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>