Skip to content

Instantly share code, notes, and snippets.

View Eeyore741's full-sized avatar
💭
🌏🌍🌎

Vitalii Kuznetsov Eeyore741

💭
🌏🌍🌎
View GitHub Profile
Существительное Количество Текст Окончание существительного
Pineapple 1 John has one pineapple (нет)
Pineapple 5 John has 5 pineapples s
Pineapple n (n != 1) John has n pineapples s
Существительное Количество Текст Окончание существительного
Ананас 0 У Джона нет ананасов ов
Ананас 1 У Джона 1 ананас (нет)
Ананас 4 У Джона 4 ананаса а
Ананас 7 У Джона 7 ананасов ов
Ананас 11 У Джона 11 ананасов ов
Ананас 21 У Джона 21 ананас (нет)
private func pineapplesCountUniversal(count: UInt) -> String{
let formatString : String = NSLocalizedString("johns pineapples count",
comment: "Johns pineapples count string format to be found in Localized.stringsdict")
let resultString : String = String.localizedStringWithFormat(formatString, count)
return resultString;
}
private func pineappleCountForRussian(count: UInt) -> String{
if (count == 0) return "У Джона нет ананасов"
if (count % 10 == 1
&&
count % 100 != 11) {
return String.init(format: "У Джона %u ананас", count)
}
Noun Count Expected text Noun ending
Ананас 0 У Джона нет ананасов ов
Ананас 1 У Джона 1 ананас (no)
Ананас 4 У Джона 4 ананаса а
Ананас 7 У Джона 7 ананасов ов
Ананас 11 У Джона 11 ананасов ов
Ананас 21 У Джона 21 ананас (no)
private func pineapplesCountForEnglish(count: UInt) -> String{
if count==0 {
return "John has no pineapples";
}
else
if (count > 1) {
return String.init(format: "John has %u pineapples", count)
Noun Count Expected text Noun addition
Pineapple 1 John has one pineapple (no)
Pineapple 5 John has 5 pineapples s
Pineapple n (n != 1) John has n pineapples s
String.init(format: "John has %u pineapple", a)
int count = 0;
NSString *johnsPineapplesCount = nil;
johnsPineapplesCount = NSLocalizedString(@"johns pineapples count", nil);
johnsPineapplesCount = [NSString localizedStringWithFormat:johnsPineapplesCount, count];
int count = 0;
NSString *johnsPineapplesCount = nil;
johnsPineapplesCount = NSLocalizedString(@"johns pineapples count", nil);
johnsPineapplesCount = [NSString localizedStringWithFormat:johnsPineapplesCount, count];
//count == 0, johnsPineapplesCount == "У Джона нет ананасов"
//count == 1, johnsPineapplesCount == "У Джона 1 ананас"
//count == 4, johnsPineapplesCount == "У Джона 4 ананаса"
//count == 7, johnsPineapplesCount == "У Джона 7 ананасов"