Skip to content

Instantly share code, notes, and snippets.

@steppefox
Created October 24, 2013 18:05
Show Gist options
  • Save steppefox/7142143 to your computer and use it in GitHub Desktop.
Save steppefox/7142143 to your computer and use it in GitHub Desktop.
Plural function for russian language
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