Ingredients/units plural form for other languages #3214
czubamich
started this conversation in
Feature Request
Replies: 1 comment
-
For what it's worth here is a page compiling all of the rules that different languages use: https://www.unicode.org/cldr/charts/46/supplemental/language_plural_rules.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Please provide a concise description of the problem that would be addressed by this feature.
In languages other than English, plural forms for ingredients and units are more complicated.
To improve the user experience in other languages, it is necessary to implement a feature that allows defining plural forms depending on the rules in the language. And I think this feature would be welcome for polish, russian, arabic, lithuanian etc users.
From what I have noted there can be up to 6 different forms (Zero, One, Two, Few, Many, Other), though it highly depends on the language (in english there are 2 (One, Many), but for polish there are 4 (One, Few, Many, Other).
This feature is needed the most for food ingredients, since for units we can use abbreviations. Though this probably also applies there.
Please provide a concise description of the feature that would resolve your issue.
I think the simplest solution would be to allow users to define rules for their as shown belown language (initially, although this could be just predefined) and, then if it's defined when configuring a food ingredient, the user could choose to use this feature and provide a list of forms for that food ingredient.
For example for english there would be a simple rule for 2 forms (though we don't need this feature in this case)
(n ==1) ? {singular} : {many}
but for polish it would be more complex:
(n==1 ? {singular} : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? {few} : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? {many} : {other})
Though for simplicity of implementation instead of {singular},{few},{many} and {other} this function would just return the index of the element in the list we define for the integredient/unit.
Also I think this configuration should be independent of the ingredient/unit name, since variations may not include the form the name appears.
Example eggs (jajka) as countable ingredient, butter and milk as measured with different form than ingredient name (masło, mleko):
Please consider and list out some caveats or tradeoffs made in your design decision
One trade-off is that units can be countable and measurable.
Again for example in polish if we gave potates as count the would be
but as measure in grams, teaspoons etc it would be a special form
If it was possible to flag the unit behavior as countable or measurable we could only use plural form if not some dedicated form (the one currently implemented), and solve this, though it's up to discussion how it would work.
Also I didn't account for negative amounts, but I guess it's not an issue.
Additional Information
Beta Was this translation helpful? Give feedback.
All reactions