Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

As you might know, different languages have a different number of plural forms available for them. The simplest example is one month and many months in English, vs. one miesiąc, one and a half miesiąca, two-three-four miesiące, and many miesięcy in Polish. This is a challenge in localization if you want to localize your applications or web content and a sentence contains a number of items as a variable instead of as a specific number.

...

Plurals syntax in particular file formats

JSON with ICU

Note

IMPORTANT!

Note that the ICU syntax is only handled as plurals in JSON files!

The ICU content is inside curly brackets. It starts with the name of a variable, which can be used in the segment, but does not have to. Then it specifies whether this is a selection of plurals or selection of some other fixed variables. Then it lists keywords and has the sentences in curly brackets immediately after each keyword.

...

Code Block
languagepy
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: enUS\n"
"Plural-Forms: nplurals=2; plural=n != 1;"

#: sample
#, python-format
msgid "Selected %(num_items)s item"
msgid_plural "Selected %(num_items)s items"
msgstr[0] ""
msgstr[1] ""

msgid ""
"I am a sample normal segment"
msgstr ""
Note

IMPORTANT!

A PO file with plurals contains a Plural-Forms: (…) line in its metadata, and every segment with plurals must have an adequate line too. XTM Cloud uses this line to identify that the file contains plurals and exactly how many of them there are. On target generation, this line will be replaced with one that is appropriate for the target language.

Plural forms will be activated in PO files straight away if XTM Cloud finds a Plural-Forms: (…) line in the file, as described above. Additionally, the msgid_plural element must be present for each segment that is supposed to be processed as plurals.

...