In English, handling plural forms of numbers is generally straightforward. Usually, you add an ending to the singular form. For example: 1 comment, 2 comments.
In Ukrainian, there are three plural forms. For example: 1 коментар, 2 коментарі, 10 коментарів.
Drupal provides the function format_plural:
format_plural($count, $singular, $plural, array $args = array(), array $options)
$count
- numeric value determining the quantity;$singular
- singular form;$plural
- plural form.
This function outputs the phrase with the correct pluralization based on the number.
For example, displaying the number of invites:
format_plural($count, '@count comment', '@count comment');
Afterward, add the corresponding translations at admin/config/regional/translate/translate
:
@count comment — @count коментар
@count comments — @count коментарі
@count[2] comments — @count[2] коментарів
Thus, depending on the value of @count
, the correct plural form will be displayed (1 коментар, 2 коментарі, 11 коментарів, 31 коментар, etc.).