Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel6
outlinefalse
styledefault
typelist
printabletrue

Introduction

This article describes all the specifics provides details of how ICU plural plurals syntax can be processed in XTM Cloud, explaining what is possible, and what is not.

...

What is ICU plurals syntax?

While nouns only have two forms in the English language only has two forms (example: one – month, other – months), other languages can have up to 6 forms (e.g. example, Polish: one – miesiąc, few – miesiące, many – miesięcy, other – miesiąca). The Using ICU plurals syntax allows , you to can encode multiple versions of a particular sentence, depending on the value of a number variable. This is especially useful in the localization industry.

Example Sample syntax looks as follows:

Code Block
languagejson
{num, plural, zero {Selected {num} items} one {Selected {num} item} two {Selected {num} items} few {Selected {num} items} many {Selected {num} items} other {Selected {num} items}}

The first argument (“numeral” num in this example) is the name of a variable . Based on the value of this variable, the that will be used to choose which version of the sentence should be selected. The application interpreting the syntax will select the appropriate version of the sentence according to the value of this variable.

The second argument (“plural” in this example) informs that the variable holds a numeric value. Alternatively, a “select” argument can be used, which specifies that the variable holds a text value corresponding to a keywordplural or select) indicates whether the variable should be interpreted using pluralization rules or based on specific keywords (for non-numeric values). In general, if the second argument is plural, the variable from the first argument has a numeric value. If the second argument is select, the variable will hold a text value.

Following the two arguments, there is a list of keywords: zero“zero”, one“one”, two“two”, few“few”, many“many”, other “other” when using plural“plural”, or a custom set of keywords when using select“select”.

Code Block
languagejson
{gender, select, female {She is here} male {He is here} other {They are here}}

Keyword The keyword “other” must always be present, as it is the one used by default.

Each keyword is followed by a sentence in curly brackets that corresponds to the plural form named by the keyword before it. These sentences can have contain variables in curly brackets, but do not have to have themdo so. You can use '#' as a number variable in plural “plural” (instead of writing the full variable name in curly brackets). If you do not want something (e.g. curly brackets) to be treated as a syntax element, you can escape them it using an apostrophe.

You can find out which plural form keyword corresponds to which particular numbers in a given particular language here: Language Plural Rules.

While this syntax allows nesting, it is recommended to limit it This syntax does permit nesting but we recommend that nesting is limited if possible.

It is also recommended to always have We also recommend that you always enter a full sentence inside plural syntax, instead of just the word that changes in your source language. This is because, in the target languages may language, more words might need to change more words within in the sentence, to properly translate it correctly.
These recommendations (explained in more detail) can be found hereYou will find more details about these recommendations in an article concerning ICU plural messages: Formatting Messages.

When creating an ICU plural message, you can use the Online ICU Message Editor to check if it works as you expect.

...

How does XTM Cloud handle

...

ICU plurals syntax?

A ticket for the XTM Support team needs to be created to To request a configuration that processes the ICU plurals syntax efficiently, optimizing the translation process for youyou need to create a ticket for the XTM Support team.

JSON files

In JSON files, we can activate our special ICU plurals parser, which interprets the ICU plurals syntax and adds or removes plural forms for translation, depending on the target file.

The parser (usually a project-level filter template) needs to be selected before uploading a file is uploaded (during the project creation , or before uploading a new file is uploaded to the project), as the number of plural forms is being adjusted during the initial analysis of a given file.

The number of target plural forms is preconfigured based on in accordance with the documentation for cardinal plural rules for languages: , described in Language Plural Rules. If needednecessary, the default plural forms can be changed for any given a particular language.

To help with translation, we can extract the plural (or select) form name as part of the segment ID, which improves matching and ensures the linguists that Linguists know which form they are translating.

As with Like any other JSON file, other metadata can also be extracted.

As of nowCurrently, when a JSON file is processed with the ICU parser enabled, you need to should avoid the following:

  • Putting variables in a double curly bracket ({{name}}), even outside ICU syntax.

  • Using characters other than letters, numbers, underscores, and commas inside variables in curly brackets.

This is because the whole entire file is being read with the ICU parser , and these kinds of variables variable cause syntax errors during the analysis.

XTM Cloud does not yet currently support numbered plural forms (in which, for example, a plural version is chosen for a specific number, e.g. . For example, =7 days can be called a week, “week” or =0 days can be called “no days” instead of “0 days”).
When a numbered form is used in the source file, it will not be returned into to the target file.

Files

...

that do not have JSON format

In files other than whose format is not JSON, there is no ICU syntax parser is available yet, in XTM Cloud. The XTM Support team can only set up configure custom variables to convert the syntax elements that these non-JSON files contain into inline tags.

Thanks to this, the Consequently, ICU plurals syntax is partially protected from modification, but the inline tags must be placed carefully placed, to ensure that everything works as expected.

The target file will have contain exactly the same plural forms as the source file has, which and Linguists can only be fixed fix this by linguists adding the missing forms manually (requiring them to have syntax knowledge about the target language). Furthermore, the segmentation way the file is segmented will not be ideal, as it often leaves all the forms will often be left translated within in one segment.