OpenRefine: Plurals don't work for i18n package

Describe the bug

The i18n package is missing the CLD rule parser, so plurals don’t work for many languages.

To Reproduce Per https://github.com/OpenRefine/OpenRefine/issues/1858#issuecomment-637274292

$.i18n().locale = 'en';
$.i18n("$1 de $2 {{plural:$2|page|pages}}", 5, 10);
$.i18n().locale = 'fr';
$.i18n("$1 de $2 {{plural:$2|page|pages}}", 5, 10);

The last line gives this:

project-bundle.js:28751 Uncaught ReferenceError: pluralRuleParser is not defined
    at Object.getPluralForm (project-bundle.js:28751)
    at Object.convertPlural (project-bundle.js:28751)
    at Object.plural (project-bundle.js:28744)
    at Object.emit (project-bundle.js:28744)
    at project-bundle.js:28744
    at Function.map (project-bundle.js:504)
    at Object.emit (project-bundle.js:28744)
    at Object.parse (project-bundle.js:28739)
    at a.parse (project-bundle.js:28723)
    at Function.e.i18n (project-bundle.js:28723)

Proposed solution Include https://github.com/santhoshtr/CLDRPluralRuleParser/blob/8baf9aedc428924fe6ee508b3d952cb5564efb3a/src/CLDRPluralRuleParser.js (and perhaps https://github.com/santhoshtr/CLDRPluralRuleParser/blob/8baf9aedc428924fe6ee508b3d952cb5564efb3a/data/plurals.json)

(check for the appropriate version to match the version of Wikimedia i18n that we’re using)

OpenRefine:

  • Version 3.4 beta - current master

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@tfmorris @antoine2711 Thank you both for collaborating on those doc improvements! Gracias! Merci!

Reopening. @antoine2711 @thadguidry feel free to reopen issues yourselves if testing demonstrates that they’re not really fixed.

I think you personally would find the jQuery migration very interesting.

@thadguidry: yes, I would love it. I have a busy schedule and no free time (I’m steeling time now), but I like to code OR and contribute, so yes. In order not to generate chatter here, I’ll cut short.

I will propose a PR for this issue to fix the problem of plurals in “FR”, till we figure for jQuery.

Regards, Antoine

@antoine2711 There’s a long standing issue to migrate jQuery for us… but it is now a bit more involved. Not impossible, but a bit involved. In fact, I think probably now involves a double-migration, but I could be wrong?

1st thing would be updating the jQuery migrate plugin.

If you have approximately 40 hours to spare 😃 … You can get started reading about migrating here: https://jquery.com/upgrade-guide/3.0/