How to provide support for foreign languages in android applications?

3

How to internationalize a TextView on Android, could someone give me an example.

     <TextView
     android:id="@+id/textView4"
     android:layout_width="0dp"
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:text="Resultado: "
     android:textAppearance="?android:attr/textAppearanceLarge" />
    
asked by anonymous 04.04.2015 / 18:01

1 answer

4

To support foreign languages, you should create a values- "cod" folder - where "cod" is a two-letter code that identifies the language for which you are supporting. You can check this table to see the code for other languages - inside the res and insert a strings.xml file into the values- "cod folder translated into the desired language.

Ex: If you want to support, for example, Spanish and French, you should create two values-en and values- / strong> in the res folder, and you must create two strings.xml files - each with a translation into one language - in the corresponding folders:

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

The strings.xml file inside the values-en folder looks like this:

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

And the strings.xml file inside the values-fr folder looks like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="title">Mon Application</string>
  <string name="hello_world">Bonjour le monde !</string>
</resources>

For more information:

04.04.2015 / 18:47