All plural APIs recommend write singular value with "1" value instead of "@count".
* @param string $singular
* The string for the singular case. Make sure it is clear this is singular,
* to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not
* use @count in the singular string.
Do not use @count in the singular string.
This line is misleading and can cause problems.
This recommendation can be found in core:
\Drupal\Core\StringTranslation\PluralTranslatableMarkup::__construct
\Drupal\Core\StringTranslation\TranslationInterface::formatPlural
Drupal.formatPlural
(drupal.es6.js)
The problem is that not only "1" can have singular value in different languages.
E.g. in Russian "21", "31", "41" and so on is singular value: "51 товар" (51 products), but not "11".
This is handled by formula "Plural-Forms: nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));\n"
.
The translation strings is:
msgid "1 product"
msgid_plural "@count products"
msgstr[0] "1 товар"
msgstr[1] "@count товара"
msgstr[2] "@count товаров"
So in that case new PluralTranslatableMarkup(21, '1 product', '@count products')
will return "1 товар" (1 product).
The solution is easy — we need use "@count" for singular value as well. In that case problem is not exists. new PluralTranslatableMarkup(21, '@count product', '@count products')
will return "21 товар" (21 products).
At least we need to change documentation and suggest to use "@count" for singular value. Also, it will require to change all plural strings.