Busy localization - support for plurals
Introduction
As you know Busy supports many languages right now, and more and more are coming everyday, thanks to contributions in Crowdin project https://crowdin.com/project/busy. I also participate in this translation project and because I am Polish, one thing still bugs me. In Polish localization there is no plural forms of words like "votes", "comments", "likes" and so on. English language uses two forms, while in Polish we have four, and in Welsh there is even six forms. You can check, plural language rules for different languages here http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html.
Suggestion
Implement pluralizers package https://www.npmjs.com/package/pluralizers into Busy platform. This will also require to update .json localization templates according to this https://formatjs.io/guides/message-syntax/#plural-format:
Each language should use English pluralizers function as default, unless someone create proper function for it. I can do it for Polish. Information about this feature could be inserted in Crowdin project page.
Here is example function code for Polish, basing on Russian example from github repo:
'use strict';
module.exports = function(entry, count) {
var key;
var m10 = count % 10;
var m100 = count % 100;
if (count === 0 && 'zero' in entry) {
key = 'zero';
} else if (count === 1) {
key = 'one';
} else if ([2, 3, 4].indexOf(m10) >= 0 && [12, 13, 14].indexOf(m100) < 0) {
key = 'few';
} else if (m10 === 0 || [5, 6, 7, 8, 9].indexOf(m10) >= 0 || [11, 12, 13, 14].indexOf(m100) >= 0) {
key = 'many';
} else {
key = 'other';
}
return entry[key];
};
Thank you for the reading.
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey,
We are currently thinking about updating the way we handle translations, because they are not very flexible. We currently use
react-intl
for this, but might switch to some other solution.It should get better soon.
Hey @donpepe I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
nice to transi.
Your contribution cannot be approved yet because it is attached to the wrong repository. Please edit your contribution and fix the repository to reapply for approval.
Please post Busy's official repo.
You may edit your post here, as shown below:
You can contact us on Discord.
[utopian-moderator]
Hi @deathwing, it is fixed. Thanks.
You got a 0.28% upvote from @upme requested by: @donpepe.
Send at least 1.5 SBD to @upme with a post link in the memo field to receive upvote next round.
To support our activity, please vote for my master @suggeelson, as a STEEM Witness