Android XML files

How to translate your android app

Hint: your resource xml files don't have to be prepared for translation; simply upload them as source files to Text United translation project. Alternatively, Text United can get the resource files directly from your GitHub or BitBucket repository. This approach is useful especially if you want to have an automated process, and content scanned for translation in regular intervals.

As you build your apps, remember not to hard-code any strings. Instead declare all strings in a default strings.xml file. Strings in strings.xml file can be extracted, translated and integrated back into your app (with appropriate qualifiers) without any changes to compiled code.

If you generate images with text, put those strings in strings.xml as well, and regenerate the images when needed.

File description

A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings:


XML resource that provides a single string.

String Array

XML resource that provides an array of strings.

Quantity Strings (Plurals)

XML resource that carries different strings for pluralization.


Strings files associate text in an app (the value) with another string (the key). Text United uses the key to identify the text in the user interface and then translates that text.

Note: A string is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). So, you can combine string resources with other simple resources in the one XML file, under one  element.

File location

The filename is arbitrary. The  element's name will be used as the resource ID.

Make sure that your apps can run properly regardless of language or locale by providing a complete set of default resources. The app's default resources are those that are not marked with any language or locale qualifiers, for example those stored in res/drawable/ and res/values/. If your apps attempt to load a resource that isn't available in the current language or in the default set, they will crash.

Whatever the default language you’re using in your apps, make sure that you store the associated layouts, drawables, and strings in default resource directories, without language or locale qualifiers.

Multilingual App

Suppose that your application's default language is English. Suppose also that you want to localize all the text in your application to French, and most of the text in your application (everything except the application's title) to Japanese. In this case, you could create three alternative strings.xml files, each stored in a locale-specific resource directory:

  • res/values/strings.xml 

Contains English text for all the strings that the application uses, including text for a string named title.

  • res/values-fr/strings.xml 

Contain French text for all the strings, including title.

  • res/values-ja/strings.xml 

Contain Japanese text for all the strings except title


TIPP: Design a single set of flexible layouts

As you create your layouts, make sure that any UI elements that hold text are designed generously. It’s good to allow more space than necessary for your language (up to 30% more is normal) to accommodate other languages. Also, elements should be able to expand horizontally or vertically to accommodate variations in the width and height of UI strings or input text. Your text strings shouldn’t overlap borders or the screen edge in any of your target languages.


If you keep all of your default strings in a strings.xml file, you can quickly extract them for translation, and once the translated strings are integrated back into your app with appropriate qualifiers, your app can load them without any changes to your compiled code. If you generate images with text, put those strings in strings.xml as well, and re-generate the images after translation.


More info:
String resources:

Localization Checklist: