How to support foreign languages in android apps?

Asked

Viewed 56 times

3

How to internationalize a TextView on Android, someone could 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" />
  • I think what you meant was: How to provide foreign language support in android apps. Right?

  • yes, for example if an outside country lowers the translated by local language or into English.

1 answer

4


To support foreign languages, you must create a folder values-"Cod" - where "Cod" is a two letter code that identifies the language you are supporting. You can refer to this table to view other languages' code inside the folder res and insert into the folder values-"Cod" an archive xml strings. translated into the desired language.

Ex.: If you want to support, for example, Spanish and French, you should create two folders values-es and values-fr inside the briefcase res, and should create two files xml strings. - each with translation into a language - in the corresponding folders:

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

The archive xml strings. inside the briefcase values-es would look 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 file xml strings. inside the briefcase values-fr would look 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:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.