Opened 6 years ago

Closed 5 years ago

#10755 closed enhancement (fixed)

Plural forms support in Locale Kit

Reported by: KapiX Owned by: pulkomandy
Priority: normal Milestone: R1
Component: Kits/Locale Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

As in topic, it would be nice if we had support for plurals in Locale Kit.

Example: In English there are only two forms: plural and plurals. In Polish there are three: liczba, liczby, liczb.

Change History (11)

comment:1 by pulkomandy, 6 years ago

A more complete example of polish wording to use as a test would be nice. How would a sentence such as: "1 object selected" "2 objects selected" translate?

comment:2 by Wizard, 6 years ago

Wybrano 1 obiekt. Wybrano 2, 3, 4 obiekty. Wybrano 5, 6, 7.. 21 obiektów. Wybrano 22, 23, 24 obiekty. Wybrano 25, 26.. 31 obiektów. Wybrano 32, 33, 34 obiekty. Wybrano 35 obiektów. And so forth. 111-120 looks like 11-20, so Wybrano 113 obiektów.

comment:3 by Wizard, 6 years ago

Simmilar rules apply in other slavic languages.

comment:5 by pulkomandy, 6 years ago

ICU manages this:

They use a pattern system which allows to "fold" all the rules into a string:

      UnicodeString msgPatEn = "{0,plural, one{# dog} other{# dogs}}";
      UnicodeString msgPatSl = "{0,plural, one{# pes} two{# psa} few{# psi} other{# psov}}";

the # is replaced with the value. The rules are defined by KapiX second link for all languages. Polish uses "one", "few", "many", and "other".

Does that format sound right for translators?

comment:6 by beos_zealot, 6 years ago

Similar rules applies to Lithuanian language:

Pažymėtas 1 objektas Pažymėti 2-9 objektai Pažymėta 10-20 objektų Pažymėtas 21 objektas Pažymėti 22-29 objektai Pažymėta 30 objektų Pažymėtas 31 objektas Pažymėti 32-39 objektai Pažymėta 40 objektų ...

nplurals=3 *

plural=0 means ending '-as' plural=1 means ending '-ai' plural=2 means ending '-ų'

(*) http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html lt / Lithuanian / nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 or n%100>=20) ? 1 : 2);

UPDATE:

Lithuanian uses categories "one", "few", "many", and "other". (*2)

Difference from previous example that these rules covers one additional case: many - for floating-point values

example: Pažymėta 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, … objekto

one (-as, same as plural=0 in previous example) few (-ai, same as plural=1 in previous example) many (-o, for floating-point values, rule f != 0) other (-ų, same as plural=2 in previous example)

(*2) http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html Name: Lithuanian / Code: lt

Last edited 6 years ago by beos_zealot (previous) (diff)

comment:7 by KapiX, 6 years ago

Does that format sound right for translators?

Yes, it is OK, but how it would be used in translations?

Wybrano %n {0,plural, one{# obiekt} few{# obiekty} many{# obiektów} other{# obiektu}}.

Like that?

comment:8 by pulkomandy, 6 years ago

You don't need the %n, the "0" is the identifier for each number in the message. So "10 files in 3 folders" would be (for english):

 "{fileCount, plural, one{# file} other{# files}} in {folderCount, plural, one{# folder} other {# folders}}"

Then this can be replaced with the rules for each translation. Of course it seems a good idea to have a "comment" with the expected rendering of the string in english, to help people understand what to do with this.

comment:9 by bonefish, 6 years ago

FWIW, multiple plural support is not the only thing we aren't supporting: http://site.icu-project.org/design/formatting/select

comment:10 by pulkomandy, 5 years ago

comment:11 by pulkomandy, 5 years ago

Resolution: fixed
Status: newclosed

Implemented in hrev47971. All places in the code where this is needed have to be updatd to make use of the new system. Let me know if you find more of those (I fixed the ones mentionned above already).

All translations have to be updated using the syntax mentionned above.

Note: See TracTickets for help on using tickets.