Android Localization

Android Localization Tutorial

Android Localization – An android program can operate on many devices in various regions. To make the application more interactive, the application should manage text,numbers,files e.t.c with techniques appropriate to the locales where the application will be utilized.

Just how of changing string into different dialects/languages is named as Android localization

android localization

In this android localization tutorial we will describe , ways to localize the application relating to different areas e.t.c. We will localize the strings found in the application form, and just as other activities can be localized.

Android Localizing Strings

To be able to localize the strings found in the application , make a fresh folder under res with name of valueslocal where local could be the replaced with the spot.

For example, regarding italy, the valuesit folder would be produced under res. It really is shown in the image below

android localization

Once that folder is manufactured, duplicate the strings.xmlfrom default folder to the folder you have created. And change its material. For example, i’ve changed the worthiness of hello there_world string.

Italy, res/values-it/strings.xml

<;?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="hello_world">Ciao mondo!</string>
</resources>

Spanish, res/values-it/strings.xml

<;?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="hello_world">Hola Mundo!</string>
</resources>

 

Aside from these languages, the spot code of other dialects have been given in the stand below

Country          Code               Folder

Japanese                      Ja                                 values-ja

French                          Fr                                 values-fr

German                        de                                 values-de

Arabic                           Ar                                 values-ar

Bengali                         bn                                 values-bn

Czech                             cs                                  values-cs

Android Localization Example

To test out android localization example , you can run this on a genuine device or within an emulator.

Steps     Description

  1. You use Android studio to produce an Android program under a package com.example.androdevelopment.myapplication.
  2. Modify the res/layout/activity_main to include respected XML components
  3. Modify the res/values/string.xml to include necessary string components
  4. Run the application form and choose a working google android device and mount the application onto it and check the results

Content ->  res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools" 
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" 
   tools:context=".MainActivity">
   
   <TextView android:text="Wifi" 
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/textview"
      android:textSize="35dp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Andro Development"
      android:id="@+id/textView"
      android:layout_below="@+id/textview"
      android:layout_centerHorizontal="true"
      android:textColor="#ff7aff24"
      android:textSize="35dp" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hindi"
      android:id="@+id/textView2"
      android:layout_below="@+id/textView"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="50dp"
      android:textColor="#ff59ff1a"
      android:textSize="30dp" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/marathi"
      android:id="@+id/textView3"
      android:textSize="30dp"
      android:textColor="#ff67ff1e"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/arabic"
      android:id="@+id/textView4"
      android:layout_below="@+id/textView3"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="42dp"
      android:textColor="#ff40ff08"
      android:textSize="30dp" />
      
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/chinese"
      android:id="@+id/textView5"
      android:layout_below="@+id/textView4"
      android:layout_alignLeft="@+id/textView3"
      android:layout_alignStart="@+id/textView3"
      android:layout_marginTop="42dp"
      android:textSize="30dp"
      android:textColor="#ff56ff12"
      android:layout_alignRight="@+id/textView3"
      android:layout_alignEnd="@+id/textView3" />

</RelativeLayout>

Content -> res/values/string.xml.

<resources>
   <string name="app_name">My Application</string>
   <string name="hello_world">Hello world!</string>
   <string name="action_settings">Settings</string>
   <string name="hindi">एंड्रॉ डेवलपमेंट</string>
   <string name="marathi">Andro विकास</string>
   <string name="arabic">أندرو التنمية</string>
   <string name="chinese">安德罗发展 </string>
</resources>

 

Let’s make an effort to run our android localization app we just customized. I assume you’d created your AVD while doing Android Environment Setup. To perform the app from Google android studio, wide open one of your project’s activity documents and click Run Eclipse Run icon from the toolbar. Google android studio installs the iphone app on your AVD and begins it if everything is okay with your set up and application, it’ll display pursuing Emulator window.

android localization

See Also:

Android Location Based Services

Android Google Maps