forked from Ludeon/RimWorld-ru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguageWorker_Russian.cs
130 lines (125 loc) · 2.78 KB
/
LanguageWorker_Russian.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
namespace Verse;
public class LanguageWorker_Russian : LanguageWorker
{
public override int TotalNumCaseCount => 3;
public override string ToTitleCase(string str)
{
return GenText.ToTitleCaseSmart(str);
}
public override string Pluralize(string str, Gender gender, int count = -1)
{
if (str.NullOrEmpty())
{
return str;
}
if (!TryLookupPluralForm(str, gender, out var plural, count))
{
plural = PluralizeFallback(str, gender, count);
}
if (count == -1)
{
return plural;
}
if (TryLookUp("Case", str, 1, out var result) && TryLookUp("Case", plural, 1, out var result2))
{
return GetFormForNumber(count, str, result, result2);
}
return plural;
}
private string PluralizeFallback(string str, Gender gender, int count = -1)
{
char c = str[str.Length - 1];
char c2 = ((str.Length >= 2) ? str[str.Length - 2] : '\0');
switch (gender)
{
case Gender.None:
switch (c)
{
case 'o':
return str.Substring(0, str.Length - 1) + "a";
case 'O':
return str.Substring(0, str.Length - 1) + "A";
case 'E':
case 'e':
{
char value2 = char.ToUpper(c2);
if ("ГКХЖЧШЩЦ".IndexOf(value2) >= 0)
{
switch (c)
{
case 'e':
return str.Substring(0, str.Length - 1) + "a";
case 'E':
return str.Substring(0, str.Length - 1) + "A";
}
}
else
{
switch (c)
{
case 'e':
return str.Substring(0, str.Length - 1) + "я";
case 'E':
return str.Substring(0, str.Length - 1) + "Я";
}
}
break;
}
}
break;
case Gender.Female:
switch (c)
{
case 'я':
return str.Substring(0, str.Length - 1) + "и";
case 'ь':
return str.Substring(0, str.Length - 1) + "и";
case 'Я':
return str.Substring(0, str.Length - 1) + "И";
case 'Ь':
return str.Substring(0, str.Length - 1) + "И";
case 'A':
case 'a':
{
char value = char.ToUpper(c2);
if ("ГКХЖЧШЩ".IndexOf(value) >= 0)
{
if (c == 'a')
{
return str.Substring(0, str.Length - 1) + "и";
}
return str.Substring(0, str.Length - 1) + "И";
}
if (c == 'a')
{
return str.Substring(0, str.Length - 1) + "ы";
}
return str.Substring(0, str.Length - 1) + "Ы";
}
}
break;
case Gender.Male:
if (IsConsonant(c))
{
return str + "ы";
}
switch (c)
{
case 'й':
return str.Substring(0, str.Length - 1) + "и";
case 'ь':
return str.Substring(0, str.Length - 1) + "и";
case 'Й':
return str.Substring(0, str.Length - 1) + "И";
case 'Ь':
return str.Substring(0, str.Length - 1) + "И";
}
break;
}
return str;
}
private static bool IsConsonant(char ch)
{
return "бвгджзклмнпрстфхцчшщБВГДЖЗКЛМНПРСТФХЦЧШЩ".IndexOf(ch) >= 0;
}
}