entropic-dev / entropic

🦝 :package: a package registry for anything, but mostly javascript 🦝 🦝 🦝
https://discourse.entropic.dev/
Apache License 2.0
5.29k stars 151 forks source link

nitpick(web): avoid ternary for plurals [WIP - do not merge yet] #303

Closed smikes closed 5 years ago

smikes commented 5 years ago

Change Type (Feature, Chore, Bug Fix, One Pager, etc.)

Nitpick

Description

It's much easier to internationalize when code is not mixed with formatting. count == 1 ? "" : "s" in particular is hard to deal with: some languages have singular, dual, plural ; some languages have a special plural for numbers >= 5, etc.

How to test

Not yet tested.

Checklist

andria-dev commented 5 years ago

Note: you can mark a PR as a Draft

Instead of completely removing plural functionality, would it not be better to abstract this functionality to a separate function (avoids ternary but keeps plurals)?

nahanil commented 5 years ago

I feel like #115 is probably relevant here and some kind of general consensus on how i18n/l10n/etc will work needs to be reached before going too far down the rabbit hole 🤷‍♂ .

chrisdickinson commented 5 years ago

Thanks for the PR! We are thinking along the same lines, I believe. However, I'd prefer to replace these ternaries with ngettext (or similar) as part of an i18n pass through the codebase. If you (or anyone else) is interested in organizing efforts around that, that would be awesome. A good first step would be to open a discussion about what approach to use on the Discourse. (I also understand that that's a much more involved effort, so do not worry if you don't have time for it!)