minetest / minetest_game

Minetest Game - A lightweight and well-maintained base for modding [https://github.com/minetest/minetest/]
http://minetest.net/
Other
1.41k stars 568 forks source link

Grammar bug in bookshelf and vessels shelf #3076

Open Wuzzy2 opened 7 months ago

Wuzzy2 commented 7 months ago

This is a grammatical error.

If you put exactly 1 book in a bookshelf, the infotext says it has "1 empty books". If you put exactly 1 glass bottle in a vessels shelf, the info text says it has "1 items".

Wuzzy2 commented 7 months ago

Unfortunately, the Minetest TR format does not support numerus (e.g. singluar/plural in English).

So a workaround for this would be to slightly repharse the string. Instead of writing "n items", write "Items: n" or something like that.

appgurueu commented 7 months ago

Alternative workaround: Add a second translation string for the singular case (good enough for languages which distinguish this case).

Alternative rephrasing of the string: Parenthesize the plural: book(s). Not sure how well this works in other languages.

Wuzzy2 commented 7 months ago

The problem with the "alternative workaround" is that it doesn't work.

Many languages do NOT have a singlular/plural system like English. Check out this list: https://www.unicode.org/cldr/cldr-aux/charts/29/supplemental/language_plural_rules.html

appgurueu commented 7 months ago

The problem with the "alternative workaround" is that it doesn't work.

As said, it works good enough for language which have a singular/plural system. Other languages can still use a rephrasing in their translation of the plural case if it would need to be further distinguished; there is no need to make the English formulation suck for this.

Montandalar commented 6 months ago

This comes back to an issue with the way translation is handled based on source language strings as the key: What if in other languages, there could be more than one translation that needs to be performed for pluralisation, declension and so on?

The Minetest built-in translator is a 1:1, bijective function*. It can't act as a relation and there's no apparent way to feed it information to reduce such a relation into a function. The only way we can get multiple output strings is to vary the source strings. There are extensions to the basic idea of translating strings that add more information. For instance, the WordPress environment has additional arguments in some functions for context, and plural/singular form.

That still leaves out languages with other forms, like special cases for two of something or "a small number of", as Wuzzy mentioned - and I will add a few more links: Linguistics StackExchange Are there any languages with different plural forms for different numbers? and Wikipedia's article on Grammatical Number.

But I have already seen what Wuzzy seems to consider bodges in terms of plural and declension in existing translations of Minetest mods. Let me see what I have in terms of / for alternation of declined forms in my installed mods:

./travelnet/locale/travelnet.es.tr:This %s belongs to %s. You can't remove or edit it.=Este/esta %s pertenece a %s. No puede eliminarlo ni editarlo.
./travelnet/locale/travelnet.de.tr:This %s belongs to %s. You can't remove or edit it.=Diese/dieser %s gehört %s. Du kannst es weder bearbeiten noch entfernen.
./doxy_mini_tram/minitram_konstal_105/locale/minitram_konstal_105.cs.tr:Front Driver Stand=Přední sedadlo řidiče/ky
./doxy_mini_tram/minitram_konstal_105/locale/minitram_konstal_105.cs.tr:Rear Driver Stand=Zadní sedadlo řidiče/ky
./minetest_doc_basics/locale/doc_basics.it.tr:When nothing is wielded, players use their hand which may act as tool and weapon. The hand is capable of collecting dropped items by punching.=Quando non si impugna nulla, gli/le utenti usano la loro mano che può fungere come strumento e arma. La mano può raccogliere gli oggetti lasciati a terra colpendoli.

Note how the practice transcends any particular language, and is used for plural and gender; it is used in German, Spanish, Czech, Italian. Again, with (s) for plural, it has a precedent of being used and translated:

./i3/locale/i3.fr.tr:@1 new recipe(s) discovered!=@1 nouvelle(s) recette(s) découverte(s)!
./techage_modpack/signs_bot/locale/signs_bot.de.tr:please check the added line(s)=bitte prüfe die neue(n) Zeile(n)
./techpack/smartline/locale/smartline.de.tr:Insert destination block number(s)=Zielblocknummer(n) eingeben

Of course, there are exceptions; sometimes the translation avoids it:

./techpack/smartline/locale/smartline.de.tr:Input the player name(s) separated by blanks,=Gebe sie Spielernamen getrennt durch Leerzeichen ein,

I think in this case, perfect is the enemy of good. It is better to have a simple singular & plural in English and allow it to be translated into many languages, perhaps however imperfectly, instead of waiting indefinitely for the perfect translation APIs to do it with. That is a discussion for the engine or a 3rd party i18n mod to have.

*I will accept that it may not be considered injective if we include instances where the translator has written the same string as a translation for multiple source strings, but this isn't typically a good translation.

Wuzzy2 commented 6 months ago

By the way: Gettext has solved this problem ages ago.

appgurueu commented 6 months ago

By the way: Gettext has solved this problem ages ago.

That solution is out of scope for MTG; that is a MTE discussion to be had. At the MTG level, all we can do is consider which workaround works best given the current engine capabilities.

Montandalar commented 6 months ago

By the way: Gettext has solved this problem ages ago.

gettext manual link: 11.2.6 Additional functions for plural forms

So it boils down to a C expression that resolves plural forms into the right string, placed at the top of a locale file. That certainly has its pros and cons. It also makes me wonder if Minetest mods would all need to put the same boilerplate at the top of locale files. But it's definitely a discussion for the engine to have about how it will extend the translation functions. I don't think it's Minetest Game's place to make its own i18n library.