Pages

Building Android App With multiple Language Support

Android App Localization


Android one of the very famous operating systems with billions of customers in more than 200 countries and also moving forward on a daily basis.

so if you are going to develop an android app and want that app to become famous worldwide, made that app localized.
Building Android App With multiple Language Support



What is Localization:
word Localization means doing things to the appropriate country or region.
In any application, there are lots of text, images, audio, video, graphics, and currency that will be used, so make it familiar with every country and region is called the localization of an application.

Considering your app to an appropriate region and country will help to reach the application word wide, and this will also help to make the application famous word wide.
if your app is multi-language support definitely it will reach and love by more and more users. 

on Play Store, there are lots of application which rating is down on lack of multi-language support.
Keep in mind, if you are going to develop applications make its multi-language support.

In this blog, I'm developing a multi-language support app, here I'm localizing only string resources,
since its a very small app, I'm giving only four language support-
  1. English(default one)
  2. Hindi
  3. German
  4. French
Working of String Localization in the android app:
The android default language is English, if you are developing an app it's default language will auto set to English.
And android loads the string resource for English from res->value->string.xml.
here is the point, If you want to give multi-language support to your application, you need to create a value folder and the name of the value folder is value-ISO language codei.e. value-hi where "hi" is the ISO language code for the Hindi language.
same for french is value-fr, german value-de, etc.

now think about how it will change the language,
when the user changes the language of the OS the android will check for that language, is any string resource file has defined or not for that language, if resource defined for that language, android will pick string resource from there, if not it will show the default on which is English.

Note- make sure you must have to define all your string in default string resource which is string.xml in value folder.

An important point to support multi-language:

Define all your string in the string.xml file.

 
<string name="empty_field">Field can not be empty</string>

and use it in XML file like this.
<TextView... android:text="@string/empty_field"/>

and with java code use like this:
field.setText(R.string.empty_field);

Never hard code the string, neither in XML file nor in Java file.


Let's start :

  1. Start a new project.
  2. Now create three more folders under res.
  • value-hi/string.xml (Hindi)
  • value-fr/string.xml (French)
  • value-de/string.xml (German)

Just for the info, I am using Google Translate service to translate the string in another language.
look here first the default string resource for English value/string.xml



Hindi value-hi/string.xml



German value-de/string.xml



French value-fr/string.xml




Finish your application setup and launch the app, now your app will launch in English.
if you want to switch the language go to,
Setting-> "language and input" and change the language to Hindi or German or French, come back to your app,
and you will see that your application is now showing in the selected language.



     

No comments:

Post a Comment