Skip to content

Instantly share code, notes, and snippets.

@olexth
Last active August 29, 2015 13:55
Show Gist options
  • Save olexth/8729980 to your computer and use it in GitHub Desktop.
Save olexth/8729980 to your computer and use it in GitHub Desktop.
Declension for words in russian language depending on count between current word. More about declension: http://en.wikipedia.org/wiki/Russian_grammar#Declension_of_numerals
- (NSString *)stringFromCount:(NSUInteger)count
{
NSString *days = nil;
NSUInteger modulo10 = count % 10;
if (modulo10 == 1)
{
days = NSLocalizedString(@"день", nil);
}
if (modulo10 == 2 || modulo10 == 3 || modulo10 == 4)
{
days = NSLocalizedString(@"дня", nil);
}
if (modulo10 >= 5 || modulo10 == 0 || (count >= 11 && count <= 14))
{
days = NSLocalizedString(@"дней", nil);
}
return [NSString stringWithFormat:@"%i %@", count, days];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment