This guide describes how to work with pluralization in Phrase.
In the English language, there is only one singular and one plural form for a string, e.g. “1 hotel” and “2 hotels”. Other languages (Russian, Arabic and many more) have very different grammars that contain additional plural forms.
Translators should pay attention to the pluralization rules of the locale they are supposed to translate and only fill out the forms they actually need.
How Phrase handles pluralization
Phrase knows about the pluralization rules of each language. Whenever you add a locale to your project and enter its ISO code, Phrase can support you with the pluralization process by only displaying the correct input fields for that language.
How to disable/enable pluralization
Pluralization can be enabled on a per-key basis. To mark a key as having pluralized translations, just edit the key settings and mark it as pluralized. Make sure to enter a pluralized name as well if required by the format you’re using (e.g. when using Gettext).
Since i18n/YAML allows the zero key for all locales, Phrase displays the input fields for zero for every key as well although only some languages require the zero explicitly.
Using pluralization with YAML/Ruby i18n
The Ruby i18n gem uses named categories to identify the different pluralizations of a message. These categories are stored as subkeys of the message key itself and are named accordingly:
For a key named inbox.messages.notification the following pluralizations will be available:
You have no new messages
You have one new message
You have %[count] new messages
When uploading a YAML file, Phrase will identify pluralized keys and mark them accordingly. It will also store the already given pluralized translations as well. During the download process, Phrase will reconstruct the YAML document and put all pluralizations under their appropriate key.
Using pluralization with Gettext
The Gettext format has a tight connection to the pluralization rules of the locale it contains. The concept basically contains of two aspects:
Header definition: nplurals
By selecting the correct language name for your locale within Phrase, the correct nplurals-definition can be fetched and will automatically be added to the file when you download it.
Phrase automatically limits the pluralization categories in the exported files to the forms that are required for the selected locale. This ensures you will always receive valid Gettext files that provide proper pluralized translations. Phrase will map the correct forms automatically for you.