Localization
The project describes how to port an application in more than one language.
Underlying Algorithm:
Basic description of algorithm in step by step form:
Basic description of algorithm in step by step form:
1.) Create a Project LocalizationExample
2.) Open and insert following in main.xml:
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/iclLayout">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"android:background="@drawable/background"
android:id="@+id/countryimage"android:layout_above="@+id/infotext"></ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"android:text="@string/info_text"
android:layout_alignParentBottom="true"android:textColor="@color/White"
android:textSize="24dip" android:layout_centerHorizontal="true"
android:id="@+id/infotext"></TextView>
android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/iclLayout">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"android:background="@drawable/background"
android:id="@+id/countryimage"android:layout_above="@+id/infotext"></ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"android:text="@string/info_text"
android:layout_alignParentBottom="true"android:textColor="@color/White"
android:textSize="24dip" android:layout_centerHorizontal="true"
android:id="@+id/infotext"></TextView>
</RelativeLayout>
3.) Create and insert strings for various languages in Values/strings.xml. The structure should be shown as below:
4.) Run the application.
Steps to Create:
1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. LocalizationExample. Enter following information:
Project name: LocalizationExample
Build Target: Android 2.3.3
Application name: LocalizationExample
Package name: org.example.LocalizationExample
Create Activity: LocalizationExample
Build Target: Android 2.3.3
Application name: LocalizationExample
Package name: org.example.LocalizationExample
Create Activity: LocalizationExample
On Clicking Finish LocalizationExample code structure is generated with the necessary Android Packages being imported along with LocalizationExample.java. LocalizationExample class will look like following:
package org.examples.LocalizationExample;
import android.app.Activity;
import android.os.Bundle;
import android.os.Bundle;
public class Localization extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Output –The final output:
English(US)
If you browse JOME -> Menu -> Settings -> Languages -> Select language and change the handset’s default language as follows:
Then on re-launching the localization app it will give you some different output in the language you selected as default.
English(India)
English(India)
Franche
No comments:
Post a Comment