Android Localization Support Different Language Tutorial

Android Localization allow you to support different or multiple language on many android devices. It will automatically change according to the device default language if the android application had define the string on that language. Android Localization is the act of changing string into different languages. Therefore, it will detect according to the string resources  in the mobile application. In this tutorial, I will give you all the steps to create the android localization to make it support multiple language in the android app.

Android Supported Language List

http://stackoverflow.com/questions/7973023/what-is-the-list-of-supported-languages-locales-on-android

This link provide a list of supported language locales on the android operating system.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “LocalizationExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Create Android resource file

Add a new resource file by right click the res package > New > Android resource file.

android localization

In the available qualifiers list select Locale and Click >> Button. Select the language u want for example I select Chinese language then click Ok.

android localization

Edit strings.xml and strings.xml(zh)

You will see new strings.xml (zh) created in your values folder. Insert below code to the specify file.

strings.xml

<resources>
    <string name="app_name">LocalizationExample</string>
    <string name="hello">Hello</string>
</resources>

strings.xml (zh)

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">LocalizationExample</string>
    <string name="hello">哈咯</string>

</resources>

Edit activity_main.xml layout

Go to your activity_main xml and edit your textView.

<?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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.questdot.localizationexample.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="32dp"
        android:text="@string/hello"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

Run your Project

Now, you can start your project in your android device. You need to go Settings to change your default language to Chinese so you can see the text are change according to the settings.

(Android Localization)

Source Code

 

(Visited 745 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

1 Response

  1. Summer Wine says:

    If you want to efficiently translate an app, a website, a game, or another software product, check out the localization management platform https://poeditor.com

    It’s very useful for collaborative localization projects.

Leave a Reply

Your email address will not be published. Required fields are marked *