Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: default language of strings.xml

I'm going to translate my application strings.xml file. Which is default language of strings.xml file? because now i need to support italian (the language with i've write strings.xml for now) and english. Should i use string.xml for english and create

res/values-it/

folder for italian, and translate "default" strings.xml in english?

like image 421
giozh Avatar asked Mar 25 '14 10:03

giozh


Video Answer


2 Answers

strings.xml is the default and will be used if there is no country specific file like res/values-it/strings.xml or res/values-fr/strings.xml. Read more about Localizing with Resources.

I would personally use strings.xml with english translations as a fallback as you already suggested.

like image 186
Kai Avatar answered Oct 30 '22 10:10

Kai


Take a look here; as stated:

Create Locale Directories and String Files

To add support for more languages, create additional values directories inside res/ that include a hyphen and the ISO country code at the end of the directory name. For example, values-es/ is the directory containing simple resourcess for the Locales with the language code "es". Android loads the appropriate resources according to the locale settings of the device at run time.

Once you’ve decided on the languages you will support, create the resource subdirectories and string resource files. For example:

MyProject/ res/ values/ strings.xml values-es/ strings.xml values-it/ strings.xml

Add the string values for each locale into the appropriate file.

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

For example, the following are some different string resource files for different languages.

English (default locale), /values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
  <resources>
    <string name="title">My Application</string>
    <string name="hello_world">Hello World!</string>
</resources>

Italian, /values-it/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
  <resources>
    <string name="title">la mia domanda </string>
    <string name="hello_world">ciao mondo!</string>
  </resources>

Note:You can use the locale qualifier (or any configuration qualifer) on any resource type, such as if you want to provide localized versions of your bitmap drawable. For more information, see Localization.

like image 21
Himanshu Agarwal Avatar answered Oct 30 '22 10:10

Himanshu Agarwal