4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

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.

Screenshot from 2018-01-04 10-59-02.png

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:
Screenshot from 2018-01-04 12-18-16.png

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

12 upvotes $3.70

Replies (7)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: