Transifex

  • Documentation
  • Localization tips & workflows
  • Working with Plurals and Genders

Working with Plurals and Genders

Transifex supports a part of the ICU MessageFormat under the JSON file format for plural rules. If you have content encoded in ICU, you can use the JSON file format 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 a good support for it.

PO files can support context and also 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 explicitly tell the translator how to translate the string.

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 Transifex web editor:

Male.jpg#asset:7367Female.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

The number of plural forms for each specific language are automatically identified and displayed in the Transifex editor. So, if a translator wants to submit a translation for a pluralized string, they have to translate all the available plural forms in order to be able to save the translation. Otherwise, the save button won't be enabled and the translation won't be submitted.

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] "Ваш суд заканчивается через % @ дня"

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

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

TM & Pluralized Strings

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

  • 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


  • For each phrase you select, you will be able to 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. Please note that only suggestions for the "Other" form will be available.

  • 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 so as to be aligned with the specific form. Once you are done with all the forms, you can save the translation by clicking "Save".

    suggestions_plurals.png#asset:4712