Topic: How to fix Plural-Forms

palino
Avatar
Topic Opener
Joined: 2022-12-19, 07:06
Posts: 16
OS: Windows 11
Version: master
Ranking
Pry about Widelands
Posted at: 2024-12-07, 22:29

Hello

In Slovak translation files there is historically wrong Plural-Forms field, now:

"Plural-Forms: nplurals=4; plural=(n % 1 == 0 && n == 1 ? 0 : n % 1 == 0 && n >= 2 && n <= 4 ? 1 : n % 1 != 0 ? 2: 3);\n"

and should be:

"Plural-Forms: nplurals=3; plural=(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);\n"

For example in this snippet:

msgid "%u Player"
msgid_plural "%u Players"
msgstr[0] "%u hráč"
msgstr[1] "%u hráči"
msgstr[2] "%u hráčov"
msgstr[3] "%u hráčov"

all msgstr[3] could be removed, because they are duplicate of msgstr[2]

I can propose PR for all related .po files, but what about Transifex? Will such change automatically propagate or some manual change on web is needed too?


Top Quote
OIPUN
Avatar
Joined: 2020-11-17, 08:34
Posts: 256
Ranking
Tribe Member
Location: Czech
Posted at: Yesterday 11:34

And when we are discussing the languages. Czech language has the same issue. On the internet I found this table. But it seams to be wrong. The attached table would make more sense. Can someone explain the categories? Or put here a link where more informations can be found?

Edited: Yesterday 11:35

Attachment: image/png
Snímek obrazovky 2025-04-14 122718.png

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 2120
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: Yesterday 11:54

Plural rules have many competing standards depending on interpretation of the language and grammar. The most reliable may be CLDR/Unicode: https://www.unicode.org/cldr/charts/46/supplemental/language_plural_rules.html

Looks like Czech has a Singular form for n=1, a Few form for integral n=2..4, an Other form for other integer values, and a Many form for non-integer (decimal) values.

The table you attached uses different names, but the form named Two is commonly only used for languages with a rule "n=2" (e.g. Arabic).

Edit: Note that Widelands only uses ngettext with non-negative integers, so the decimal forms are unused for us.

Edited: Yesterday 11:55

Top Quote
OIPUN
Avatar
Joined: 2020-11-17, 08:34
Posts: 256
Ranking
Tribe Member
Location: Czech
Posted at: Yesterday 12:10

Nordfriese wrote

Edit: Note that Widelands only uses ngettext with non-negative integers, so the decimal forms are unused for us.

In this case, I agree with palino, only 3 forms are needed for our languages. As for now, for all Czech strings msgstr[2] =msgstr[3] in Transifex. msgstr[3] can be removed.


Top Quote
palino
Avatar
Topic Opener
Joined: 2022-12-19, 07:06
Posts: 16
OS: Windows 11
Version: master
Ranking
Pry about Widelands
Posted at: Yesterday 12:21

We continued discussion in this closed PR: https://codeberg.org/wl/widelands/pulls/5017

I realised that 3rd form (msgstr[2] "%u hráčov" or Category many of unicode page) is not another plural form, but it is special case for any number with a fractional part. In Slovak Genitive case is used, I suppose similar in Czech. So e.g. this could be formally correct tranlation for you:

msgstr[0] "%u hráč"
msgstr[1] "%u hráči"
msgstr[2] "%u hráče"
msgstr[3] "%u hráčů"

(even it doesn't make sense to have fractional part of players, but I think you get the point)

Actually I haven't seen any fractional numbers in widelands' strings - like %f or %g, but translation can support it.


Top Quote
OIPUN
Avatar
Joined: 2020-11-17, 08:34
Posts: 256
Ranking
Tribe Member
Location: Czech
Posted at: Yesterday 13:13

Ok, fractinoal=decimal 1/2 dne/hráče = 1.5 dne/hráče. I remember having a discussion with GunChleoc on this topic few years ago. But my old Transifex account is deleted so I couldn't return to it. I just remember us coming to a conclusion that msgstr[2] should be translated the same way as msgstr[3]. It is probably wrong, but doesn't cause any problems when msgstr[2] is not used. Should it be used in the future, it will need correction.


Top Quote