Created
October 24, 2013 18:05
-
-
Save steppefox/7142143 to your computer and use it in GitHub Desktop.
Plural function for russian language
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
| function plural_str(i, str1, str2, str3){ | |
| function plural (a){ | |
| if ( a % 10 == 1 && a % 100 != 11 ) return 0 | |
| else if ( a % 10 >= 2 && a % 10 <= 4 && ( a % 100 < 10 || a % 100 >= 20)) return 1 | |
| else return 2; | |
| } | |
| switch (plural(i)) { | |
| case 0: return str1; | |
| case 1: return str2; | |
| default: return str3; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment