CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.08k stars 4.1k forks source link

Irregular plurals #72948

Open Uwuewsky opened 4 months ago

Uwuewsky commented 4 months ago

Describe the bug

  1. Some messages of actions on multiple objects omit their number before their pluralized name, which is incorrect for languages where there are more than two plural forms.
  2. In some menus, items with charges are displayed in singular after their number in any locale.

Attach save file

N/A

Steps to reproduce

  1. Omitted numbers: get some rocks, drop them down: b1 It doesn't matter if the object has charges or not: b4-2 Butcher the carcass, the number of items is also omitted: b6-1

Slightly different case, in the aiming menu it would be better if the ammo name was always in the singular. Now it is in plural, you can see it if the ammo has some noun in its name, like grenades. b3-1

  1. Objects with charges in the singular: In the &-create and *-build menu, items with charges are always displayed in the singular, e.g. nails. b5-1 b5-2 These items have plural form, as you can see in the screenshot: b5-3

Expected behavior

  1. Add numbers in front of the names (no, gettext can't output the indefinite plural form, it needs to specify the number)
    You drop down: folding knife
    You drop down: 4 folding knifes

    Not dropping 1 is also an option

    You harvest: 1 rabbit skull
    You harvest: 2 chunks of meat
  2. Add conversion to plural form
    8 nails

Screenshots

No response

Versions and configuration

VERSION: cdda-experimental-2024-03-23-0552 bbda3e4

Additional context

No response

Qrox commented 4 months ago

Related: in Chinese we normally add a classifier between the number and the noun, so the current way of prepending the number directly looks awkward in Chinese too.

I have been thinking of specifying how a language needs to use the number, classifier, and noun in JSON, probably something to this effect, and I think this should also be able to solve your issue.

"name": {
    "noun": { "str_sp": "strawberries" },
    "classifier": { "str": "%1$d handful of %2$s", "str_pl": "%1$d handfuls of %2$s" },
}

Here %1$d would be the number, %2$s would be the noun, and handful of is a classifier-like construct in English, but in Chinese we use classifier for almost all nouns.

Then we can use the strings in C++ code like this:

// always prepend a number
str.translated_count( count ); // 1/2 handful(s) of strawberries, 1/2 book(s)
// omit the number `1` if allowed by the language
str.translated_multi( count ); // strawberries, 2 handfuls of strawberries
// omit the number if allowed by the language
str.translated( count ); // strawberries, book(s)

This should also be able to solve your problem by always formatting the number in the classifier field. It should also be useful for classifier-like constructions in English and other languages such as a handful of something, so instead of saying you pick up your handful of strawberries, it says something more sensible like you pick up your strawberries. Furthermore, this should allow localizing to languages that use the number, classifier, and noun in an order other than number-classifier-noun.

But there's the problem of adding too many unnecessary strings for other languages and I didn't quite have the time to work on it either.

I also heard there are more sophisticated localization libraries out there so we could probably use one of these instead, but I don't know if Transifex supports such libraries.