Smartling supports plural sensitive translation of strings. In order for strings to have pluralized translations, your development platform must also be able to support plural strings in your resource files. Your application development platform will determine exactly how you can create plural strings in your Smartling project. Typically, this is achieved through special APIs/Functions/Methods that allow the developer to identify strings that need to be pluralized and provide a quantity variable. The appropriate form of the string is selected at runtime according to the quantity variable and the language. Smartling currently supports plural strings in YAML, Gettext, QT TS Linguist, Android XML and iOS files, as well as in Global Delivery Network (GDN) projects.

Smartling’s support for plurals is based on the Unicode CLDR standard. We support two CLDR forms for English; One and Other (which correspond to the ‘singular’ and ‘plural’ forms in English grammar). If a string is captured as a plural string, we will ask translators to provide the correct number and type of forms - based on CLDR - for each language. We will then deliver the translations in the correct number of forms in the translated file or via the localized GDN site. The number of forms for a specific target language can be more or less than the forms for the source language.

Best Practices for Working with Plurals

  • Carefully review your native support (platform or selected library) and avoid “rolling your own” solution for plurals.
  • Keep plural strings simple; use only a single quantity variable in a string.
  • Include the quantity variable in all of the original forms of the string to avoid confusing translators.

In your application code, deploying a plural string will look something like this:


String rooms = format(‘rooms_available', $rooms_available_count);

In this example, $rooms_available_count is the quantity variable, used to look up the correct form of the rooms_available string. In a YAML file, your rooms_available might look something like this:


     one: “%{rooms_available_count} room available.”
     other: “%{rooms_available_count} rooms available.”

Avoid constructions like these:


# Do NOT do this this is example of something not supported.
     zero: “Zilch.”
     # Zero is not a standard form for English in CLDR.
     one: “Last room available.”
     # Each standard form should refer to the quantity variable.
     other: “%{rooms_available_count} rooms available.”

Plural strings should conform to the CLDR standards for plural forms, should always refer to the quantity variable and should only differ as much as is necessary for correct grammar in the target language. If you want to handle a specific quantity in a special way, for example: “Sorry, there are no rooms available!” or “Hurry, there is only one room left!”, use conditional statements to fetch a different string.

Plurals for Gettext Files

Plural sensitive forms for Gettext files are indicated by the source .pot file having a string marked ‘msgid_plural’.


msgid “added %d item to cart”
msgid_plural “added %d items to cart”
msgstr[0] “”
msgstr[1] “”

Once translated, the downloaded .po file will have the plural forms needed for the target language and the appropriate language-specific headers. Smartling returns the PluralForm header in the top of the file (if it existed in the original file) that contains the correct plurals rules for that locale.

Gettext files have limited support for some locales. For more information on Gettext plural forms, see: Additional functions for plural forms

Plurals for YAML Files

Plural sensitive forms for YAML files are indicated at the sub-key level. For example, the one and other keys in the following English source file indicate that the string is plural sensitive:


     one: "uploaded %{num_secs} second ago"
     other: "uploaded %{num_secs} seconds ago"

You can turn off detection of plurals using the following directive: # smartling.plurals_detection = off

Plurals for JSON Files

Plurals are supported for JSON files if the entire file is formatted as ICU MessageFormat. JSON files uploaded with the Smartling string directive for ICU MessageFormat can have plural strings when using the ICU MessageFormat plural string type. ICU MessageFormat encompasses a number of features for formatting strings in addition to plurals. Here are some examples of the ICU MessageFormat plural strings in a JSON file:


{{ "1" : "{quantity, plural, one {{quantity} thing here.} other {

things here.}}",}}
{{ "2" : "{quantity, plural, one

{# item here.}
other {# items here.}}",}}
{{ "3" : "{quantity, plural, one

{# \"fancy thing\" here.}
other {# \"fancy things\" here.}}",}}
{{ "4" : "{quantity, plural, one

{# tweet here '#'tweet-counter.}
other {# tweets here '#'tweet-counter.}}"}}}

Plurals for QT TS Files

Plural sensitive forms for QT Linguist files are indicated by the source string having “numerus = “yes” “ and the variations using the “numerusform” element with the “plurality” attribute.


<message numerus="yes">
  <source>%1 subtitle(s) extracted</source>
     <numerusform plurality="singular">%1 subtitle extracted</numerusform>
     <numerusform plurality="plural">%1 subtitles extracted</numerusform>

Plurals for Android Files

Plural sensitive forms for Android files are indicated by the source file having a string marked plurals.


<plurals name="plural_strings2">
   <item quantity="one">You have %s item in your cart.</item>
   <item quantity="other">You have %s items in your cart.</item>

Smartling conforms to the Android standard for plurals: http://developer.android.com/guide/topics/resources/string-resource.html#Plurals.

Plurals for iOS Files

While Apple has now released the Stringsdict format to handle plurals, Smartling has previously extended iOS strings format by developing an open source library to accommodate plurals.

Plural sensitive forms for iOS files are indicated by source files with strings in the following form:



Where: KEY is the original key string rule is one of the plural forms: zero, one, two, few, many, other, and conforms to the CLDR specification on plural forms. Smartling loads a translation following rules as defined under CLDR.

Here are sample resource files for the key %d songs found:



/* Number of songs from search results */

"%d songs found##{one}" = "One song found";
"%d songs found##{other}" = "%d songs found";


/* Number of songs from search results */

"%d songs found##{one}" = "Найдена одна песня";
"%d songs found##{few}" = "Найдено %d песни";
"%d songs found##{many}" = "Найдено %d песен";
"%d songs found##{other}" = "Найдено %d песен";

Plurals in the GDN

Plural strings in the GDN are identified by wrapping the quantity variable in <span class="sl_plural"> tags.

Was this article helpful?