Skip to content Skip to sidebar Skip to footer

How To Create A Multi-language App With Xml In Android?

I want to create a multi-language Android application with three languages: English, Arabic and Persian language. I must create three XML files in the assets folder and parse them

Solution 1:

You need to have different strings.xml to support different langauges.

http://developer.android.com/training/basics/supporting-devices/languages.html

What is the list of supported languages/locales on Android?.

I don't think there is support for persian language.

Example:

MyProject/

res/
   values/
       strings.xml

   values-es/
       strings.xml

   values-fr/
       strings.xml

   values-ar/          //for arabic
       strings.xml     

For spanish

<?xml version="1.0" encoding="utf-8"?><resources><stringname="title">Mi Aplicación</string><stringname="hello_world">Hola Mundo!</string></resources>

At runtime, the Android system uses the appropriate set of string resources based on the locale currently set for the user's device.

http://developer.android.com/guide/topics/resources/localization.html

TextView textView = new TextView(this);
textView.setText(R.string.hello_world);

Check the doc for more info

http://developer.android.com/training/basics/supporting-devices/languages.html

Solution 2:

Yes u need to create three type of xml.

res/
   values/
       strings.xml
   values-es/
       strings.xml
   values-fr/
       strings.xml

Refer this doc.

EDIT

Please Check this Example.So u can get idea On Multi language supporting.

Post a Comment for "How To Create A Multi-language App With Xml In Android?"