-
Notifications
You must be signed in to change notification settings - Fork 33
/
LanguageWorker_Spanish.cs
87 lines (82 loc) · 1.89 KB
/
LanguageWorker_Spanish.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
// Assembly-CSharp, Version=1.5.8874.2866, Culture=neutral, PublicKeyToken=null
// Verse.LanguageWorker_Spanish
using Verse;
public class LanguageWorker_Spanish : LanguageWorker
{
public override string WithIndefiniteArticle(string str, Gender gender, bool plural = false, bool name = false)
{
if (name)
{
return str;
}
if (plural)
{
return ((gender == Gender.Female) ? "unas " : "unos ") + str;
}
return ((gender == Gender.Female) ? "una " : "un ") + str;
}
public override string WithDefiniteArticle(string str, Gender gender, bool plural = false, bool name = false)
{
if (name)
{
return str;
}
if (plural)
{
return ((gender == Gender.Female) ? "las " : "los ") + str;
}
return ((gender == Gender.Female) ? "la " : "el ") + str;
}
public override string OrdinalNumber(int number, Gender gender = Gender.None)
{
return number + ".º";
}
public override string Pluralize(string str, Gender gender, int count = -1)
{
if (str.NullOrEmpty())
{
return str;
}
if (TryLookupPluralForm(str, gender, out var plural, count))
{
return plural;
}
if (count != -1 && count < 2)
{
return str;
}
char c = str[str.Length - 1];
char c2 = ((str.Length >= 2) ? str[str.Length - 2] : '\0');
if (IsVowel(c))
{
if (str == "sí")
{
return "síes";
}
if (c == 'í' || c == 'ú' || c == 'Í' || c == 'Ú')
{
return str + "es";
}
return str + "s";
}
if ((c == 'y' || c == 'Y') && IsVowel(c2))
{
return str + "es";
}
if ("lrndjsxLRNDJSX".IndexOf(c) >= 0 || (c == 'h' && c2 == 'c'))
{
return str + "es";
}
if (c == 'z' || c == 'Z')
{
var strWithoutLastChar = str.Substring(0, str.Length - 1);
var replacedChar = c == 'z' ? 'c' : 'C';
return strWithoutLastChar + replacedChar + "es";
}
return str + "s";
}
public bool IsVowel(char ch)
{
return "aeiouáéíóúAEIOUÁÉÍÓÚ".IndexOf(ch) >= 0;
}
}