Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from kolyvan/master

Russian plural rules
  • Loading branch information...
commit 8de57be741f38a07ef9bf1c1c7286a05f38ac465 2 parents 80f6f03 + e2ea4dc
@mattt authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 TTTLocalizedPluralString.m
View
28 TTTLocalizedPluralString.m
@@ -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];
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.