Table of contents
Associated file extensions: .xml
i18n type: ANDROID
Android uses an XML-based format for localization. There are three types of entries:
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:
Entry type: string-array
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:
Email address: account_details_array
Full name: account_details_array
Contact info: account_details_array
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:
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:
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>
Do you want to find out more about plurals in Transifex? Please check here.
Any attributes in the
plural elements can be used.
Transifex will recognize, however, a specific attribute,
translatable. 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" translatable="false">Untranslated</string>
product attribute is also recognized by Transifex Android parser and can be used for entries where the same "name" attribute has been defined.
That way, the parser will parse your content successfully without complaining about duplicate keys.
1. Without escaping special characters in the source file
2. Special characters escaped in the source file
3. Strings enclosed in double quotes
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
HTML inline tags
Double or single quotes in the following html inline tags are not escaped by Transifex Android parser:
INLINE_TAGS = ("xliff:g", "a", "annotation", "b", "em", "i", "cite", "dfn", "big", "small", "font", "tt", "s", "strike", "del", "u", "sup", "sub", "ul", "li", "br", "div", "span", "p")
Transifex also supports developer comments in Android .xml files. A valid XML comment preceding any of the elements
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:
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. In case the Proofread step is enabled, only the translations that have been proofread will be exported instead.
Download for translation as XLIFF: The translation file will be generated in the .xliff format and include both translated and untranslated strings. The latter ones will be returned without containing
Download untranslated strings as XLIFF: The translation file will be generated in the .xliff format and include only the untranslated strings.
XLIFF support is only offered on the Premium plan and up.
In addition to the above Interface options, you can use the API or Client to download the translation files according to your localization needs.
For a more detailed description of the download modes, consult the table below:
* Proofeading needs to be enabled as an option for this logic to take effect. To learn how to enable proofreading click here.