Created
September 24, 2018 14:23
-
-
Save rlisowski/20ede182df505e374a0893aafd70342d to your computer and use it in GitHub Desktop.
I18njs pluralization pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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