Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

If you want to have only one strings.xml file and you would like to localize to Italian, all you need to do is add the following line to your strings.xml file.

<resources xmlns:tools="http://schemas.android.com/tools" tools:locale="it">

locale="it" -> Italian, locale="fr" -> French, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top