Localization in Android

Localization in Android

When it comes to Language,people like to be able to read stuff in their own language.So when you are aiming your app to be globally successful, it is always a good idea to make the app localized.

What is Localization?

It requires you to add appropriate resources to your software to ensure that a given country, locale, language, or culture is supported.

The first step in the app localization process is to place your resources into external files:-

Resources

Think of resources as everything in your app that is not code: content, images, videos, etc. Resources are data files that accompany a program’s executable code. Resources simplify the code you have to write by moving the creation of complex sets of data or graphical content outside of your code and into more appropriate tools.

Accessing strings.xml from your Android code

Strings.xml file is the 'human readable' version of the localization file. Your app actually won't access this file directly. Instead when you compile your application, the SDK will also compile the strings.xml file to a binary format and generate a piece of Java code that will let you access the the file in the runtime. This Java class is typically named as R (as Resource). The R class contains all the resource element names you have in your strings.xml and in other resource files. This allows easy access to these resources just by using the final variable R.

Adding new languages:   

To add new language, all you have to do is create a new folder named ‘values’ for each new language you want to support. For example, if you want to support hindi language, you just need to create your strings.xml file in  ‘res\values-hi’  which will have values for all strings in hindi and last step you need to do is specify your locale in code and  you are ready to go!!!

Things need to be kept in mind while doing localization :-

  1. Default resources :-  Ensure that your app runs properly, regardless of language or locale, by maintaining a set of default resources.
  2.  Flexible layout :- When designing an app you plan to localize, you need to consider spacing,left-to-right and right-to-left support,  other factors by having flexible layout so that it can accommodate both expansion and contraction of text.
  3. System-provided formatting methods :- When your app displays dates, times, numbers, currencies, and other entities that can vary by locale, use the system-provided formats rather than creating your own app-specific formats. Not every locale uses the same thousands separator, decimal separator, or percent sign.
  4. Untranslated text :- If your strings display in the source language instead of translation, you may have overlooked those strings for translation or marked the resources directory with an incorrect language qualifier.
  5. Testing :-Make sure to thoroughly test the default locale. Your application will crash if the default resources cannot be loaded for some reason (i.e. they are missing).







To view or add a comment, sign in

Others also viewed

Explore content categories