Table of Contents


Transifex supports plurals for all file formats that support them, e.g., Android, Apple strings, Apple stringsdict, Gettext, Java, JSON with ICU plurals, Structured JSON, XLIFF, YAML.

Transifex also supports a part of the ICU MessageFormat under JSON, Structured JSON, Fileless, and Java Properties. If you have content encoded in ICU, you can use one of the above types to import and export it in Transifex.

Also, the most important and frequently-used features of ICU can be supported in other file formats in a non-ICU way, such as plurals, context, and developer comments. Depending on the file format you use, you can access some or all of these features.

You can use PO files as a good way to work around this. It is one of the most popular file formats for localization, supported by many frameworks. It's quite powerful and we have good support for it.

PO files can support context and developer comments if you want to bring that info straight from the source file. If, in addition to plurals, you have genders, you can use the context field (msgctxt) to indicate the gender. You can also use the developer comment (#.) to tell the translator how to translate the string explicitly.

Here is an example showing the same source string but using the context to save two different entities in Transifex.

#. Please translate it as a MALE gender  
#: src/main.py:338
msgctxt "male"
msgid "Cousin"
msgstr ""

#. Please translate it as a FEMALE gender
#: src/main.py:340
msgctxt "female"
msgid "Cousin"
msgstr
Pluralized strings can also be defined in a .po file as follows:

#: src/main.py:340
msgid "plural"
msgid_plural "plurals"
msgstr[0] "1 plural"
msgstr[1] "%d plurals"


Viewing Genders in the Editor

Another way to specify genders is through the key name. Transifex will recognize the words, Male or Female, in a key name and display a label in the editor that shows the gender. For example, if you have the following entries in a PO file:

msgid "actor.male"
msgstr "Actor"

msgid "actor.female"
msgstr "Actress"

Then the following will appear in the Transifex web editor:

Male.jpg#asset:7367

Female.jpg#asset:7368

This same concept is applied to all file formats with a key-value structure.

Pluralized strings can also be defined in a PO file as follows:

#: src/main.py:340  
msgid "plural"
msgid_plural "plurals"
msgstr[0] "1 plural"
msgstr[1] "%d plurals"


How pluralized strings are handled by Transifex

When Transifex encounters a pluralized entry in your file, it'll associate all the plural forms together. This way, Transifex can present the translator with all the forms in the Editor. At the same time, Transifex knows how many plural forms each language has and asks the translator to translate them. Until the translator translates all the plural forms in the selected language, they won't be able to save their work.

plurals_editor.png#asset:4664
  • If a user clicks on a target plural form (e.g., few), the same form (few) is enabled in the source language. If this form does not exist in the source language, then by default, the "other" form is enabled.

  • If a user clicks on a source plural form (e.g., few), the same form (few) is enabled in the target language. If this form does not exist in the target language, then by default, the "other" form is enabled.

As an example, English has 2 plural forms ("one" and "other"). The source file will have two phrases, one for each plural form. On the other hand, Russian has 4 plural forms. So, after the translations are done, when you download the file from Transifex, your translation file will look as follows.

#: src/main.py:340
msgid "plural"
msgid_plural "plurals"
msgstr[0] "Ваш суд заканчивается через 1 день"
msgstr[1] "Ваш суд заканчивается через % @ дня"
msgstr[2] "Ваш суд заканчивается через % @ дней"
msgstr[3] "Ваш суд заканчивается через % @ дня"

Using variables in plurals

Don't use "1 car" and "%s cars" in your code. Include the variable in all cases, i.e., use this: "%s car" and "%s cars".

Why? English uses two plural rules: "one" ("1 car") and "other" ("0,2,10 cars"). But other languages, bundle the different cases in other ways. For example, in Portuguese, it's "0, 1 car" and "2, 10 cars". So, when coding, ensure you always include the variable denoting the number of objects in the string.

Transifex is following ISO Standards and Unicode CLDR data for the supported languages, as you can read in our documentation.

You can also look at the rules we follow for defining the plural forms here.


Leveraging TM with Pluralized Strings

Here is an idea of how to use the TM with plural-enabled entities.

  1. Open the Transifex Editor, click on the Search box, and filter source strings by “pluralized: yes” to only see the phrases that are marked as pluralized.

    plurals_editor_180404_161717.png#asset:4711

  2. For each phrase you select, you can see its various plural forms and toggle between them, such as "One" and "Other". On the right side of the translation box, you'll be able to see the TM suggestions for this string. If there is a 100% match and a plural match simultaneously, this will be shown next to the score with a label. It means that for the selected phrase’s plural form, a translation for this exact plural form exists in TM.

  3. To use a TM suggestion, click “Use this,” which will copy the TM entry into the translation form you are currently in. Once it is copied, you can properly modify this to be aligned with the specific form. Once you are done with all the forms, you can save the translation by clicking "Save".

Natively supporting ICU

We love the concept and idea behind ICU. It's a powerful framework when you have very advanced i18n needs. It's also a neat way to store the actual phrases in the engine itself, instead of having multiple fields. More fluid and dynamic, easier to work with as a developer.


So why aren't we natively supporting ICU and suggesting workarounds? Here are some of our thoughts on this.

ICU affects a very small percentage of users and phrases. Very, very few of our users' phrases are pluralized (eg. you rarely see plurals in marketing and user-generated content). From those few users, very few need to also support male and female versions. And out of those, less than half are willing to put the effort to support it in their code.

ICU is also a quite complex framework. The phrase itself is no longer plain English but has variables and logic in it. That's a fundamental difference, it's like replacing your house's bricks with a brick that can grow in size with a button. The change affects every single piece of a localization system like Transifex. Some examples are the Translation Memory (serializing entries when updating a TM of billions of entries is no joke!), the word count across the platform, etc.

Finally, as outlined on this page, you can support the most important ICU features with Transifex already, such as plurals.

Properly supporting ICU would mean an overhaul of many core components in Transifex. Based on the above, we are putting this functionality on hold and we will revisit it in the future once we get more customers asking for it.


Continue Reading



Did this answer your question?