Android Application with Multilanguage Support

Android is one of the operating system which is used by all over the world. So in order to develop the application people should consider about presenting it with Multilanguage support and let people to select their choice of language to be displayed. So this article describes about the concept behind the multi-language supporting application

This is not a tutorial to teach people how to do and what to do then letting them to some things. But this is about sharing knowledge and having idea about do many things. Let’s get into the point.

Before developing an application one should get an idea about what are all the folders and files are there in the development tool. Here are some important folders and their sub files in eclipse.

    • Source folder (src)
      • Java files.
    • Generated folder (Gen)
      • R file
    • Resource folder (res)
      • Value
      • Animator
      • Layout
      • Menu
      • Raw
      • Drawable
    • Library
    • Assets
    • Bin
    • Android manifest.XML file
    • Project property.txt

Source folder (src) will contain the source code of the project and it will have the .java files. These files are completely editable by the programmer.

Generated folder (gen) will be having the generated R-file which contains references to certain resources of the project. These files are .java files which are automatically generated. Better programmer should not edit this.

Resource folder (res) will be the important folder which contain physical entity like pictures, font and texts, layouts, inbuilt videos, sound, etc. these file locations are indicated by R.java file to the source code.

Library folder (library) will have external libraries or jar files witch are required for project.

Assets folder (assets) will have raw files and directories which are not compatible for device. It is just an unstructured hierarchy of files, allowing you to put anything you want there and later retrieve as raw byte streams.

Directory Structure

Bin folder (bin) will be used for compiler to create jar or .APK file that contain zipped resource files etc.

Android manifest.XML will maintain all kind of permissions and “let this do” work for an application. It interact with operating system to allow some services to be used for the particular application.

Let’s get in to the point. In order to get multi-language support we have to concentrate about strings.XML file. The folder “values” will have the style.xml which is like CSS in HTML and strings.xml which is having text content which should be presented in android application.

Strings.xml

So this strings.xml will be in the form of XML as like the figure. And this file will be completely editable and developer can give the strings values where ever he is going to use in the application. And one should be careful with giving string name with respect to the ID which will be getting entry in R.java.

<resources>
<string name="test_text">Test</string>
<string name="clear_text">Clear</string>
<string name="wifi_connection">The active connection is wifi.</string>
<string name="mobile_connection">The active connection is mobile.</string>
<string name="no_wifi_or_mobile">No wireless or mobile connection.</string>
</resources>

Assume the content of strings.xml as given above. And this is in the place where the only one string file presents. In order to get different language we have to create new folder like shown in below

Language strings.xml

Each folder should contain the different strings.xml file which are having the different language like as shown in codes.

In Deutsch(Dutch):

 <resources>
<string name="test_text">Testo</string>
<string name="clear_text"> duidelijk </string>
<string name="wifi_connection"> De actieve verbinding is wifi.</string>
<string name="mobile_connection"> De actieve verbinding mobiel.</string>
<string name="no_wifi_or_mobile"> Geen draadloze of mobiele verbinding.</string>
</resources>

In French:

<resources>
<string name="test_text"> test</string>
<string name="clear_text"> clair </string>
<string name="wifi_connection"> La connexion wifi est actif </string>
<string name="mobile_connection"> La connexion active mobile.</string>
<string name="no_wifi_or_mobile"> Pas de connexion sans fil ou mobiles.</string>
</resources>

In Hindi:

 <resources>
<string name="test_text"> कसौटी </string>
<string name="clear_text"> स्पष्ट </string>
<string name="wifi_connection"> सक्रिय कनेक्शन वाईफाई है.</string>
<string name="mobile_connection"> सक्रिय कनेक्शन मोबाइल है.</string>
<string name="no_wifi_or_mobile"> कोई वायरलेस या मोबाइल कनेक्शन.</string>
</resources>

And keep in different folder will be able to get access Multilanguage support in While changing the language setting from the settings <Settings ⇒ Language & Input >. Since the operating system recognize the languages we have to name the “value” folder under Android Localization Language ISO Codes. As shown in table.

Language Locale values/strings.xml
German de values-de/strings.xml
Chinese zh values-zh/strings.xml
Czech cs values-cs/strings.xml
Dutch nl values-nl/strings.xml
French fr values-fr/strings.xml
Italian it values-it/strings.xml
Japanese ja values-ja/strings.xml
Korean ko values-ko/strings.xml
Polish pl values-pl/strings.xml
Russian ru values-ru/strings.xml
Spanish es values-es/strings.xml
Arabic ar values-ar/strings.xml
Bulgarian bg values-bg/strings.xml
Catalan ca values-ca/strings.xml
Croatian hr values-hr/strings.xml
Danish da values-da/strings.xml
Finnish fi values-fi/strings.xml
Greek el values-el/strings.xml
Hebrew iw values-iw/strings.xml
Hindi hi values-hi/strings.xml
Hungarian hu values-hu/strings.xml
Indonesian in values-in/strings.xml
Latvian lv values-lv/strings.xml
Lithuanian lt values-lt/strings.xml
Norwegian nb values-nb/strings.xml
Portuguese pt values-pt/strings.xml
Romanian ro values-ro/strings.xml
Serbian sr values-sr/strings.xml
Slovak sk values-sk/strings.xml
Slovenian sl values-sl/strings.xml
Swedish sv values-sv/strings.xml
Tagalog tl values-tl/strings.xml
Thai th values-th/strings.xml
Turkish tr values-tr/strings.xml
Ukrainian uk values-uk/strings.xml
Vietnamese vi values-vi/strings.xml

Summery:
Duplicate the strings.xml with different language and keep “values/strings.xml” folder with renaming It with reference of ISO standard codes. Example: values-hi/string.xml.

All the best

Leave a Reply