Translatable sentences with multiple quantities

Lets say we have the sentence “You have x apples and y bananas”. Do I understand correctly that it is impossible to translate the plurals for more than one variable per sentence with gettext? If yes, is the only alternative to split it to 2 sentences or have something like “Number of apples: x, number of bananas: y”?

That is correct.

Yes. If you give us a concrete example (What is your app? Where is the source? What is the context of the string?), maybe we can provide a suggestion that will work in your specific case.

It is a small game, but I haven’t published it yet. It is already working reasonably well, but I’m using Type Script and a lot of Gnome technologies for the first time and it is a little messy. I plan to publish it soon, once I clean it up a little bit.

Not just “with gettext”, BTW. Qt’s Qtranslator::translate(), for one, has the exact same limitation: the quantity for plural translations is an argument to the translate() call itself, and there can only be one quantity value per call.

I haven’t surveyed other translation systems extensively, but it wouldn’t surprise me at all if it’s a pretty widespread restriction. My intuition tells me that the rules for how to correctly pluralize the combination of quantities present in a sentence like, “You have x apples and y bananas” could end up getting fractally more complex than the rules for how to separately pluralize either quantity in isolation, for some languages. (Considering there are already some that have 4 or more different plural forms for just a single quantity!) Start combining them, it could get to the point where it’s nearly impossible for translators to accurately define all of the permutations.

That stems from the way plurals work in many languages, where it’s more than just a singular and a plural. The gettext documentation has a list so you can see how it works if your language only has that binary distinction.

With two variables, a language which only the binary form would already require four translations (1 apple and 1 banana, 1 apple and 2 bananas, 2 apples and 1 banana, 2 apples and 2 bananas). That’s already a lot. It quickly starts exploding when you add more forms. And that’s just for two variables.

That kind of construct is just not practical to translate. That’s why tools have that “limitation”. It is not for technical reasons.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.