Created
February 18, 2014 10:17
-
-
Save rusllonrails/9068136 to your computer and use it in GitHub Desktop.
COFFEE SCRIPT PLURALIZE
This file contains 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
app.pluralize = (num, variant1, variant2, variant3)-> | |
plural = | |
if num % 10 == 1 && num % 100 != 11 | |
0 | |
else if num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) | |
1 | |
else | |
2 | |
switch plural | |
when 0 then variant1 | |
when 1 then variant2 | |
when 2 then variant3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment