Versions Compared

Key

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

Introduction

As you may 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 wish want to localize your applications or Web web content where the and a sentence contains a number of things items as a variable instead of as a specific number.

...

Supported file formats

XTM Cloud can handle the localization of plurals in four file formats:

  • Android XML;,

  • JSON with ICU syntax;,

  • PO/POT,

  • Stringdict (IOS).

By default, handling plurals is disabled.

(warning) IMPORTANT!

Keep in mind that enabling plurals

...

in your filter template comes with the change in file naming convention. The code of the project’s target language is appended to the end of the source file name. This is expected behavior and cannot be changed in any way.

Image Added

Determining the number of plurals for a

...

particular language

Keep in mind that different languages have a different number of plural forms available for them. In order to To find out more on about the actual number of plurals for a given particular language, please, visit the the following website: https://cldr.unicode-.org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html/index/downloads.

Note

IMPORTANT!

The number of plural forms in a source file should be consistent with the number of plurals in the source language. In the target file, there will be as many plurals as it is set in its corresponding target language on in the back-end side of the XTM Cloud instance (configurable by the XTM International Support team).

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 directly immediately after each keyword.

Code Block
languagejson
{
  "your-sample-plural-segment": "{num, plural, one {Selected {num} item} other {Selected {num} items}}",
  "your-sample-select-segment": "{gender, select, female {She is here} male {He is here} other {They are here}}",
  "your-sample-normal-segment": "I am a sample normal segment."
}

The In XTM Cloud, the processing of plurals in XTM is turned off disabled by default. To turn enable it on, please, raise create a proper ticket with such request to suitable ticket for the XTM International Support team and provide details (it is recommended to that you have segment ID IDs and comments set up for this).

For adjusting To adjust the plural count for a given particular target language, please, raise create a proper ticket with such request to suitable ticket for the XTM International Support team and provide details.Please, see

  • See attached an

...

  • example of a correctly-structured JSON file:.

View file
nameplural(3).json

  • Also

...

  • see the content in XTM Workbench:

...

Info

To learn more about ICU plurals syntax in XTM Cloud, read the following article: ICU plurals syntax in XTM Cloud.

Android XML

Please, see the exemplary structure of the See the example Android XML file structure. The syntax is pretty self-explanatory.

...

As in the case of JSON files, the plurals processing is also turned off by default. To turn enable it on, please, raise create a proper ticket with such request to suitable ticket for the XTM International Support team and provide details (it is recommended to that you have segment ID and comments set up enabled for this).

As The method for adjusting the default plural count for a given particular target language , it basically works in exactly the same way as for JSON ICU , as we cannot differentiate the file for which file it is being set.Please, see

  • See attached an

...

  • example of a correctly-structured Android XML file:

View file
nameandroid_plural(1).xml

  • Also

...

  • , see the content in XTM Workbench:

...

PO/POT files

PO files are bilingual but, but by default, only segments without translation translations are extracted for translation. Again, it can be adequately configured by the XTM International Support team. Please, see See an exemplary example structure:

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.

As for activating plural forms Plural forms will be activated in PO files , it will happen straight away if XTM Cloud finds a Plural-Forms: (…) line inside 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.

For adjusting To adjust the plural count for a given particular target language, please, raise create a proper ticket with such request to suitable ticket for the XTM International Support team and provide details.Please, see

  • See attached an

...

  • example of a correctly-structured PO file:

View file
nameplurals(1).po

  • Also

...

  • see the content in XTM Workbench:

...

Stringsdict files

Stringsdict files are used for translating iOS applications, and their file looks quite different from the Android filefiles:

Code Block
languagexml
<plist version="1.0">
    <dict>
        <key>Selected_items</key>
        <dict>
            <key>NSStringLocalizedFormatKey</key>
            <string>%1$#@items@</string>
            <key>items</key>
            <dict>
                <key>NSStringFormatSpecTypeKey</key>
                <string>NSStringPluralRuleType</string>
                <key>NSStringFormatValueTypeKey</key>
                <string>d</string>
                <key>zero</key>
                <string>Selected %d items</string>
                <key>one</key>
                <string>Selected %d item</string>
                <key>other</key>
                <string>Selected %d items</string>
            </dict>
        </dict>
    </dict>
</plist>

Stringsdict have plurals switched on enabled by default , and no additional configuration is required.

For adjusting To adjust the plural count for a given particular target language, please, raise create a proper ticket with such request to suitable ticket for the XTM International Support team and provide details.Please, see

  • See attached an

...

  • example of a correctly-structured Stringsdict file:

View file
nameplural(1).stringsdict

  • Also

...

  • see the content in XTM Workbench:

...