Android supports a wide range of languages.
If you want to know all the supported languages you can visit here .
Using localization concept one can display a text in a any language corresponding to his Locale.
Suppose a client(may be a person from France) is interested in getting his app design in English when he is in a country where the locale is English and in his country he would be looking to see his app in French. In this situation we can use Localization.
Consider the following screen shots :
The first snapshot is HELLO WORLD in French.
When ever we change the Locale to France we can see the HELLO WORLD in French language.
For this to happen we must do the following :
If u consider the 13-th line : Here i am setting the text to the TextView using a value in strings.xml file like below :
<string name="text">HELLO WORLD</string>
<string name="text">BONJOUR TOUT LE MONDE</string>
Whenever the Locale changes the appropriate values folder will be used.
If you want to know all the supported languages you can visit here .
Using localization concept one can display a text in a any language corresponding to his Locale.
Suppose a client(may be a person from France) is interested in getting his app design in English when he is in a country where the locale is English and in his country he would be looking to see his app in French. In this situation we can use Localization.
Consider the following screen shots :
The first snapshot is HELLO WORLD in French.
When ever we change the Locale to France we can see the HELLO WORLD in French language.
For this to happen we must do the following :
- Create a folder under the res folder with name values-fr. Here 'fr' refers to French language.
- Create a strings.xml file similar to the one in the values folder.
- If we need to display a TextView in different languages in different Locales, set the text of the textview using the strings folder.
Consider the following :
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
- <TextView
- android:id="@+id/main_TV_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:layout_marginLeft="38dp"
- android:layout_marginTop="29dp"
- android:text="@string/text"
- </RelativeLayout>
If u consider the 13-th line : Here i am setting the text to the TextView using a value in strings.xml file like below :
<string name="text">HELLO WORLD</string>
- Now in the strings.xml file of values-fr folder write HELLO WORLD in french (use Google translator )
<string name="text">BONJOUR TOUT LE MONDE</string>
Whenever the Locale changes the appropriate values folder will be used.
Testing it in emulator :
Go to settings --> Language & keyboard --> Select Language --> and select Français(France).
Later when you run your application again you can see BONJOUR TOUT LE MONDE displayed on the screen.
We can also use .ttf files which i will discuss in the next post.
Any suggestions are welcomed.
Please comment if anyone has some or the other problem with this one.
Comments
Post a Comment