Versions Compared

Key

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

Plural variants are used whenever a numeric value is being dynamically passed into a translation string to ensure the accuracy and readability of sentences when there are zero, one or multiple things being referenced.

Singular and plural indicators

For plurals, we create different versions of a key followed by an underscore and the plural /or singular version indicator it represents.

Multiple 'Counts'

Has not been used yet, but the documentation can be read here.

How to use them

...

Code Block
languagejs
{
  "key_zero": "zero",
  "key_one": "singular",
  "key_two": "two",
  "key_few": "few",
  "key_many": "many",
  "key_other": "other"
}

Most commonly, we will use the following indicator suffixes:

  • _zero for the string rendered when there are 0 of count

  • _one for the string rendered when there is 1 of count

  • _other for the string rendered when there is more than 1 of count

Using count indicators

In our JSON translation file:

Code Block
languagejs
        "status_knowntesting_zero": "We don't know about any Host LMS instances that are needed for {{consortium_name}}.", are not missing test records or accounts for any library.",
        "status_knowntesting_one": "We know aboutare missing test records or accounts for {{count}} Hostlibrary.",
 LMS instance that is needed for {{consortium_name}}.", "status_knowntesting_other": "We knoware about {{count}} Host LMS instances that are neededmissing test records or accounts for {{consortium_namecount}}.",

...

zero = the string rendered when there are 0 of count

...

one = the string rendered when there is 1 of count

...

 libraries."

In our code, we use the string without the underscore and number, and the string will automatically adapt to count.

Code Block
languagejs
t('

...

status_

...

testing', {count:

...

Here are examples of all keys which will be adapted:

Code Block
languagejs
{
  "key_zero": "zero",
  "key_one": "singular",
  "key_two": "two",
  "key_few": "few",
  "key_many": "many",
  "key_other": "other"
} 0}); // -> "We are not missing test records or accounts for any library."
t('status_testing', {count: 1}); // -> "We are missing test records or accounts for 1 library."
t('status_testing', {count: 34}); // -> "We are missing test records or accounts for 34 libraries."

Reference