Cataclysm-BN icon indicating copy to clipboard operation
Cataclysm-BN copied to clipboard

Some plural forms defined by Transifex cannot be used in game

Open olanti-p opened this issue 3 years ago • 0 comments

Transifex defines plural forms according to CLDR - that includes plural forms for floating-point numbers. However, our gettext implementation (GNU gettext) supports only unsigned integers, and defines plural forms according to that.

As an example, plural forms formula for Russian from Transifex documentation:

Plural-Forms: nplurals=4; \
    plural=(n%10==1 && n%100!=11 ? 0 : \
        n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : \
            n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);

Plural form 3 is unreachable if n is an unsigned integer.

For comparison, the formula from GNU gettext documentation:

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;

Having an unreachable unused plural form creates unnecessary work for translators, and introduces incompatibility with other translation tools that assume unsigned integer arithmetic (e.g. Poedit complains about "unused plural form").

An easy solution would be to manually configure plural rules on Transifex, but I don't know whether that's something they allow. Afaik BN does not use floating-points for user-facing data anyway (except measurement units, but that's niche), so we don't need dedicated plural form for that.

Affected languages:

  • Polish
  • Russian
  • Ukrainian

olanti-p avatar Apr 01 '21 09:04 olanti-p