-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement]: Proper plurals support for localisation #3540
Comments
Would we need separate labels in the translation file for each combination of plurals in the code? Would we need to add language specific pluralization handling everywhere? I see we can add that in Weblate easily, but not sure to handle that nicely in the code without having a lot more translation targets. Right now, we have a function which just substitutes values into the string called audiobookshelf/client/components/modals/SleepTimerModal.vue Lines 71 to 112 in 72e59e7
and the string label/value is defined here: audiobookshelf/client/strings/en-us.json Lines 622 to 624 in 72e59e7
|
If I understand this correctly, we're not using a multi-language translation library in this project (one which would automatically handle translations i.e. export and update a list of strings for translation and, presumably, provide support for plurals) and just doing string substitution? I can see why adding project-wide plurals support might be a tall order, especially if done from scratch. I'm not sure how this is usually handled in other projects. In any case, if reworking the entire localisation support is too much work and if we want to avoid creating too many new translation targets, separating strings which follow or precede a number could be an acceptable alternative. |
We can write a function that takes an optional number parameter and returns the correct plural form but I'm not seeing any examples in weblate how this is formatted |
Weblate's documentation provides a list of file formats that support plurals along with format examples, but it seems that basic json files of the "key":"translation" type are not supported. To quote their documentation:
|
Type of Enhancement
Web Interface/Frontend
Describe the Feature/Enhancement
Currently, some of the strings and labels for localisation are being reused in multiple locations without proper plurals support. While this works for English, problems arise in many inflected languages. Weblate has full support for these plural forms, so my suggestion is to separate labels/strings into "fixed" strings (meaning those that don't need plurals support) and "plural" strings require alternative translations in places where the translation depends on the number of items.
Why would this be helpful?
To take Croatian as an example, the string
LabelBooks
, if translated in the nominative case in Croatian (in plural) as "Knjige", would serve fine in the search results/search suggestions, e.g. here:However, the same word would be incorrect as a caption for the number of books available in a single library, where the translation is supposed to vary depending on the actual number of books.
Please note that in the above example with plurals the translation "knjiga/e" is my attempt to offer a correct translation for plurals of this word but some words have even more variants.
Future Implementation (Screenshot)
As per Weblate's documentation, we should have plural-supported strings. For example, the correct translation for the word "Book" in Croatian should be:
0, 1 knjiga
2, 3, 4 knjige
5-20 knjiga
21, 31... knjiga
22, 23, 24; 32, 33, 34... - knjige
25-30; 35-40... - knjiga
Audiobookshelf Server Version
v2.15.1
Current Implementation (Screenshot)
No response
The text was updated successfully, but these errors were encountered: