Open likerRr opened 6 years ago
That's not a bad idea. The only thing that's used inside the rest of polyglot is pluralTypeIndex
, but I'm not sure how generic that is (or how useful it would be to other libs), since it deals with the "smart_count" stuff.
I think it's generic enough in what it does. I see it as a module, which exports pluralTypeIndex
function as default. So anyone will be able to build very basic pluralization implementation, e.g:
import getPluralTypeIndex from 'plural-type-index';
const phrases = {
cars: ['car', 'cars'], // plural forms
};
const pluralize = (locale, phrase, count) =>
phrase[getPluralTypeIndex(locale, count)];
pluralize('en', phrases.cars, 1); // car
pluralize('en', phrases.cars, 2); // cars
So the purpose of moving code to separate lib is to make it does one thing - get pluralization index
One thing I would like to add to this if it goes into its own package, The ability to query how many sections needed/recommended for each locale.
I am going to bake it into my application directly for now, eg
{
'arabic': 6
'bosnian_serbian': 3,
'chinese': 1,
....
}
you get the idea.
What do you think of moving that part of code to a single package?
Reasons: