airbnb / polyglot.js

Give your JavaScript the ability to speak many languages.
http://airbnb.github.io/polyglot.js
BSD 2-Clause "Simplified" License
3.71k stars 208 forks source link

Make pluralization rules configurable #138

Closed schleyfox closed 5 years ago

schleyfox commented 5 years ago

Users may wish to support different locales without requiring a change or fork to the library. Additionally, some users may prefer slightly different pluralization rules for some locales.

Follow up to https://github.com/airbnb/polyglot.js/pull/137

/cc @ljharb @mereskin-zz

schleyfox commented 5 years ago

/cc @airbnb/webinfra @airbnb/polyglot-js-owners

spikebrehm commented 5 years ago

Don't forget to also update the transformPhrase() usage on line 387

schleyfox commented 5 years ago

@spikebrehm https://github.com/airbnb/polyglot.js/blob/4a43fafe220092ddda4809ac50eb9da19ffaa97a/index.js#L387 doesn't support the other polyglot option of tokenRegex, so I don't think making it configurable is within scope.

spikebrehm commented 5 years ago

The omission of the tokenRegex argument in that method was probably an oversight that we could fix here, but if you think it's out of scope, then đź‘Ť.

ljharb commented 5 years ago

It wasn’t an oversight :-) it was intentional to not expose that internal implementation detail, and i think it’s fine to add the overrides later if it’s desired.