Skip to content

Instantly share code, notes, and snippets.

@rlisowski
Created September 24, 2018 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlisowski/20ede182df505e374a0893aafd70342d to your computer and use it in GitHub Desktop.
Save rlisowski/20ede182df505e374a0893aafd70342d to your computer and use it in GitHub Desktop.
I18njs pluralization pl
I18n.pluralization["pl"] = function (count) {
var n = count || 0
var mod10 = count % 10
var mod100 = count % 100
key = "zero"
if ( n == 0 ) {
key = "zero";
} else if ( n == 1 ) {
key = "one";
} else if ([2, 3, 4].includes(mod10) && ![12, 13, 14].includes(mod100)) {
key = "few";
} else if ([0, 1, 5, 6, 7, 8, 9].includes(mod10) || [12, 13, 14].includes(mod100)) {
key = "many";
} else {
key = "other";
}
return [key];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment