APP Localization is used to provide the user interference in local languages to user for better understanding. you can see it in this tutorial.
Steps to use APPLocalization in your project.
Steps to use APPLocalization in your project.
- Crate a project(APPLocalizationDemo) in android studio.
- Create a Activity MainActivity.Java and update it-
package com.pankaj.applocalizationdemo; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //no need to do anything other for localization application //will use default device language } }
- Create a xml activity_main.xml and update it-
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:gravity="center" android:orientation="vertical" tools:context="com.pankaj.applocalizationdemo.MainActivity"> <!--create four object to show in different language--> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="@string/app_name" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="@string/app_pankaj" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="@string/app_gurjar" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="@string/app_developer" /> </LinearLayout>
- Create a resource strings.xml in values of res and update it-
<resources> <string name="app_name">App Localization Demo</string> <string name="app_pankaj">Pankaj</string> <string name="app_gurjar">Gurjar</string> <string name="app_developer">Android Developer</string> </resources>
- Create a folder values-ar in res.
- Create strings-ar.xml in this folder for Arabic language and update it-
<resources> <string name="app_name">التطبيق التعريب التجريبي</string> <string name="app_pankaj">بانكاج</string> <string name="app_gurjar">غورجار</string> <string name="app_developer">الروبوت المطور</string> </resources>
- Create a folder values-hi in res.
- Create strings-hi.xml in this folder for Hindi language and update it-
<resources> <string name="app_name">ऐप लोकलाइजेशन डेमो</string> <string name="app_pankaj">पंकज</string> <string name="app_gurjar">गुर्जर</string> <string name="app_developer">एंड्रॉइड डेवलपर</string> </resources>
- All the application development process with App Localization has completed, Now run the app and look the screen.
Note : please set your device language to english
- Now please set your device language to Hindi and open application.
- Now please set your device language to Arabic and open application.
- Good bye, Thanks to read this blog.