Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2 from kolyvan/master
Browse files Browse the repository at this point in the history
Russian plural rules
  • Loading branch information
Mattt Thompson committed May 29, 2012
2 parents 80f6f03 + e2ea4dc commit 8de57be
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions TTTLocalizedPluralString.m
Expand Up @@ -136,6 +136,32 @@
return kTTTOtherPluralRule;
}

static NSString * TTTRussianPluralRuleForCount(NSUInteger count) {

NSUInteger n10 = count % 10;
NSUInteger n100 = count % 100;

switch (n10)
{
case 1:
if (n100 != 11)
return kTTTOnePluralRule;
break;

case 2:
case 3:
case 4:
if (n100 != 12 && n100 != 13 && n100 != 14)
return kTTTFewPluralRule;
break;

default:
break;
}

return kTTTManyPluralRule;
}

NSString * TTTLocalizedPluralStringKeyForCountAndSingularNoun(NSUInteger count, NSString *singular) {
NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];

Expand Down Expand Up @@ -164,6 +190,8 @@
pluralRule = TTTSpanishPluralRuleForCount(count);
} else if ([languageCode isEqualToString:@"th"]) {
pluralRule = TTTThaiPluralRuleForCount(count);
} else if ([languageCode isEqualToString:@"ru"]) {
pluralRule = TTTRussianPluralRuleForCount(count);
} else {
NSLog(@"Unsupported language: %@", languageCode);
return nil;
Expand Down

0 comments on commit 8de57be

Please sign in to comment.