• Documentation
  • File formats
  • Android XML

Android XML

  • Associated file extensions: .xml
  • i18n type: ANDROID

Android uses an XML-based format for localization. There are three types of entries: stringstring-array, and plurals.

Entry type: string

The first type of entry contains simple strings or sentences. Each entry must have a name attribute that must be unique in a resource. This is represented as a single entry for translation in Transifex as well.

<resources>
<string name="localization_manager">Localization Manager</string>
<string name="admin_users">Administrators are people that manage the organization.</string>
<string name="contribution">Become a translator or contribute to a Transifex project.</string>
<string name="updates">Keep me up to date with Transifex news</string>
<string name="live_status">Live status of Transifex service</string>
<string name="connect_with_users">Connect with users on Transifex</string>
</resources>

In the editor, such a string will be displayed as follows:

android_strings_editor.png#asset:3049

Entry type: string-array

The string-array type also has a name attribute, which must also be unique in a resource file. Each string-array contains multiple items. These items are represented as a single translation entity in Transifex, so that it is possible to have a different number of entries in a particular language.

So, the whole content of a string-array is shown for now and the translator is responsible to create a correct list of translated items. For example:

<resources>
<string-array name="account_details_array">
  <item>username</item>
  <item>Email address</item>
  <item>Full name</item>
  <item>Contact info</item>
</string-array>
</resources>

The above items in Transifex will have the following keys assigned:

  • username: account_details_array[0]
  • Email address: account_details_array[1]
  • Full name: account_details_array[2]
  • Contact info: account_details_array[3]

The above entry lists the details of an account in English. It should be translated in French as:

<resources>
<string-array name="account_details_array">
  <item>Nom d'utilisateur</item>
  <item>Adresse de courriel</item>
  <item>Nom complet</item>
  <item>L’information de contact</item>
</string-array>
</resources>

and in Russian as:

<resources>
<string-array name="account_details_array">
  <item>имя пользователя</item>
  <item>Адрес электронной почты</item>
  <item>Полное имя</item>
  <item>Контактная информация</item>
</string-array>
</resources>

Entry type: plurals

The last type of entries, plurals, also has an attribute name (which is required to be unique as well) and contains a list of items, each one having an attribute quantity that is used to select the appropriate plural form of the string for a particular number of elements.

So, if your project's source language is, for example, English (2 plural forms), each pluralized entry has to include the following 2 plural forms:

<resources>
<plurals name="minutes_count">
<item quantity="one">%s minute</item>
<item quantity="other">%s minutes</item>
</plurals>
</resources>

In case you omit a plural form and try to upload the file to Transifex, the following error message will appear:

missing_plural_form.png#asset:3060

In case an additional plural form is included (except for "one" & "other") then the following error message will be displayed after trying to upload the file to Transifex:

additional_plural_form.png#asset:3061

After translating the above string into another language, for example, Russian, the translation file after downloading it from Transifex will look like this:

<resources>
<plurals name="minutes_count">
<item quantity="one">%s минута</item>
<item quantity="few">%s минуты</item>
<item quantity="many">%s минут</item>
<item quantity="other">%s минут</item>
</plurals>
</resources>

Attributes

Any attributes in the stringstring-array, and plural elements can be used.

Transifex will recognize, however, a specific attribute, translate. When its value is false, Transifex will ignore the specific entry and not present it to translators, either in the web editor or in the files downloaded for offline translation. For instance, the following entry will not be translated:

<string name="name" translate="false">Untranslated</string>

The product attribute is also recognized by Transifex Android parser and can be used for entries where the same "name" attribute has been defined. 

product_attribute.png#asset:3507

That way, the parser will parse your content successfully without complaining about duplicate keys.


Escape behavior

1. Without escaping special characters in the source file

android_unescaped_characters.png#asset:3

2. Special characters escaped in the source file

Android_escaped_characters.png#asset:334

3. Strings enclosed in double quotes

android_enclosed_in_double_quotes.png#as
android_enclosed_in_double_quotes1.png#a

 Note: Transifex will always remove the double quotes which enclose the string (so that they will not be presented to the translator) and escape characters when a file is requested.


4. Other examples

Android_examples.png#asset:3351

Transifex also supports developer comments in Android .xml files. A valid XML comment preceding any of the elements stringplurals or string-array will appear as an instruction in the editor.

For instance, if your source file looks like this:

<resources>
<!-- Type of entry: string -->
<string name="localization_manager">Localization Manager</string>
<!-- Type of entry: string-array -->
<string-array name="account_details_array">
  <item>username</item>
  <item>Email address</item>
</string-array>
<!-- Type of entry: plurals-->
<plurals name="minutes_count">
<item quantity="one">%s minute</item>
<item quantity="other">%s minutes</item>
</plurals>
</resources>

your translators will find the above comments as instructions under the Context tab:

instructions_android.png#asset:3086

Download options

  • Download file to translate: Any untranslated entries will be returned empty so that translators know which are the untranslated ones.
  • Download for use: All the entries that have not been translated yet won't be included in the file.
  • Download only reviewed translations: Only the reviewed entries will be included in the translation file.
  • Download for translation as XLIFF: The translation file will be downloaded in the .xliff format and include both translated and untranslated strings. The last ones will be returned without having target elements.
  • Download untranslated strings as XLIFF: The translation file will be downloaded in the .xliff format and include only the untranslated strings.

Note

XLIFF support is only offered on the Growth plan and up.

download_options.png#asset:3087

In addition to the above Interface options, you can use the API or Client to download the translation files according to your localization needs.