using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
namespace TaleWorlds.Localization.TextProcessor
{
// Token: 0x0200001B RID: 27
public class EnglishTextProcessor : LanguageSpecificTextProcessor
{
// Token: 0x06000075 RID: 117 RVA: 0x0000386C File Offset: 0x00001A6C
public override void ProcessToken(string sourceText, ref int cursorPos, string token, StringBuilder outputString)
{
char c = token[1];
if (c == 'a')
{
if (this.CheckNextCharIsVowel(sourceText, cursorPos))
{
outputString.Append("an");
return;
}
outputString.Append("a");
return;
}
else
{
if (c != 'A')
{
if (c == 's')
{
string text = "";
int num = outputString.Length - 1;
while (num >= 0 && outputString[num] != ' ')
{
text += outputString[num].ToString();
num--;
}
text = new string(text.Reverse<char>().ToArray<char>());
if (text.Length > 1)
{
string newValue;
if (this.HandleIrregularNouns(text, out newValue))
{
outputString.Replace(text, newValue);
return;
}
if (this.Handle_ves_Suffix(text, out newValue))
{
outputString.Replace(text, newValue);
return;
}
if (this.Handle_ies_Suffix(text, out newValue))
{
outputString.Replace(text, newValue);
return;
}
if (this.Handle_es_Suffix(text, out newValue))
{
outputString.Replace(text, newValue);
return;
}
if (this.Handle_s_Suffix(text, out newValue))
{
outputString.Replace(text, newValue);
return;
}
outputString.Append(c);
}
}
return;
}
if (this.CheckNextCharIsVowel(sourceText, cursorPos))
{
outputString.Append("An");
return;
}
outputString.Append("A");
return;
}
}
// Token: 0x06000076 RID: 118 RVA: 0x000039B4 File Offset: 0x00001BB4
private bool CheckNextCharIsVowel(string sourceText, int cursorPos)
{
while (cursorPos < sourceText.Length)
{
char value = sourceText[cursorPos];
if ("aeiouAEIOU".Contains(value))
{
return true;
}
if ("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ".Contains(value))
{
return false;
}
cursorPos++;
}
return false;
}
// Token: 0x06000077 RID: 119 RVA: 0x000039F8 File Offset: 0x00001BF8
private bool HandleIrregularNouns(string text, out string resultPlural)
{
resultPlural = null;
char.IsLower(text[text.Length - 1]);
string key = text.ToLower();
string text2;
if (this.IrregularNouns.TryGetValue(key, out text2))
{
if (text.All((char c) => char.IsUpper(c)))
{
resultPlural = text2.ToUpper();
}
else if (char.IsUpper(text[0]))
{
char[] array = text2.ToCharArray();
array[0] = char.ToUpper(array[0]);
resultPlural = new string(array);
}
else
{
resultPlural = text2.ToLower();
}
return true;
}
return false;
}
// Token: 0x06000078 RID: 120 RVA: 0x00003A9C File Offset: 0x00001C9C
private bool Handle_ves_Suffix(string text, out string resultPlural)
{
resultPlural = null;
bool flag = char.IsLower(text[text.Length - 1]);
char c = char.ToLower(text[text.Length - 1]);
char c2 = char.ToLower(text[text.Length - 2]);
if (c2 != 'o' && "aeiouAEIOU".Contains(c2) && c == 'f')
{
resultPlural = text.Remove(text.Length - 1);
resultPlural += (flag ? "ves" : "VES");
return true;
}
if (c2 == 'f' && "aeiouAEIOU".Contains(c))
{
resultPlural = text.Remove(text.Length - 2, 2);
resultPlural += (flag ? "v" : "V");
resultPlural += (flag ? c : char.ToUpper(c)).ToString();
resultPlural += (flag ? "s" : "S");
return true;
}
if (c2 == 'l' && c == 'f')
{
resultPlural = text.Remove(text.Length - 1);
resultPlural += (flag ? "ves" : "VES");
return true;
}
return false;
}
// Token: 0x06000079 RID: 121 RVA: 0x00003BD0 File Offset: 0x00001DD0
private bool Handle_ies_Suffix(string text, out string resultPlural)
{
resultPlural = null;
bool flag = char.IsLower(text[text.Length - 1]);
char c = char.ToLower(text[text.Length - 1]);
char value = char.ToLower(text[text.Length - 2]);
if ("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ".Contains(value) && c == 'y')
{
resultPlural = text.Remove(text.Length - 1);
resultPlural += (flag ? "ies" : "IES");
return true;
}
return false;
}
// Token: 0x0600007A RID: 122 RVA: 0x00003C5C File Offset: 0x00001E5C
private bool Handle_es_Suffix(string text, out string resultPlural)
{
resultPlural = null;
bool flag = char.IsLower(text[text.Length - 1]);
string text2 = text[text.Length - 1].ToString();
string text3 = text[text.Length - 2].ToString();
if (text2 == "z")
{
resultPlural = text;
resultPlural += (flag ? "zes" : "ZES");
return true;
}
if (this.Sibilants.Contains(text2))
{
resultPlural = text;
resultPlural += (flag ? "es" : "ES");
return true;
}
if (this.Sibilants.Contains(text3 + text2))
{
resultPlural = text;
resultPlural += (flag ? "es" : "ES");
return true;
}
if ("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ".Contains(text3) && text2 == "o")
{
resultPlural = text;
resultPlural += (flag ? "es" : "ES");
return true;
}
if (text3 == "o" && text2 == "e")
{
resultPlural = text;
resultPlural = resultPlural.Remove(resultPlural.Length - 1);
resultPlural += (flag ? "es" : "ES");
return true;
}
if (text3 == "i" && text2 == "s")
{
resultPlural = text;
resultPlural = resultPlural.Remove(resultPlural.Length - 2);
resultPlural += (flag ? "es" : "ES");
return true;
}
return false;
}
// Token: 0x0600007B RID: 123 RVA: 0x00003E00 File Offset: 0x00002000
private bool Handle_s_Suffix(string text, out string resultPlural)
{
resultPlural = null;
bool flag = char.IsLower(text[text.Length - 1]);
char c = char.ToLower(text[text.Length - 1]);
char c2 = char.ToLower(text[text.Length - 2]);
if ("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ".Contains(c))
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
if (c == 'e')
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
if ("aeiouAEIOU".Contains(c2) && c == 'y')
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
if (c2 == 'f' && c == 'f')
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
if (c2 == 'o' && c == 'f')
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
if ("aeiouAEIOU".Contains(c2) && c == 'o')
{
resultPlural = text;
resultPlural += (flag ? "s" : "S");
return true;
}
return false;
}
// Token: 0x17000014 RID: 20
// (get) Token: 0x0600007C RID: 124 RVA: 0x00003F45 File Offset: 0x00002145
public override CultureInfo CultureInfoForLanguage
{
get
{
return CultureInfo.InvariantCulture;
}
}
// Token: 0x04000035 RID: 53
private Dictionary<string, string> IrregularNouns = new Dictionary<string, string>
{
{
"man",
"men"
},
{
"footman",
"footmen"
},
{
"crossbowman",
"crossbowmen"
},
{
"pikeman",
"pikemen"
},
{
"shieldman",
"shieldmen"
},
{
"shieldsman",
"shieldsmen"
},
{
"woman",
"women"
},
{
"child",
"children"
},
{
"mouse",
"mice"
},
{
"louse",
"lice"
},
{
"tooth",
"teeth"
},
{
"goose",
"geese"
},
{
"foot",
"feet"
},
{
"ox",
"oxen"
},
{
"sheep",
"sheep"
},
{
"fish",
"fish"
},
{
"species",
"species"
},
{
"aircraft",
"aircraft"
},
{
"news",
"news"
},
{
"advice",
"advice"
},
{
"information",
"information"
},
{
"luggage",
"luggage"
},
{
"athletics",
"athletics"
},
{
"linguistics",
"linguistics"
},
{
"curriculum",
"curricula"
},
{
"analysis",
"analyses"
},
{
"ellipsis",
"ellipses"
},
{
"bison",
"bison"
},
{
"corpus",
"corpora"
},
{
"crisis",
"crises"
},
{
"criterion",
"criteria"
},
{
"die",
"dice"
},
{
"graffito",
"graffiti"
},
{
"cactus",
"cacti"
},
{
"focus",
"foci"
},
{
"fungus",
"fungi"
},
{
"headquarters",
"headquarters"
},
{
"trousers",
"trousers"
},
{
"cattle",
"cattle"
},
{
"scissors",
"scissors"
},
{
"index",
"indices"
},
{
"vertex",
"vertices"
},
{
"matrix",
"matrices"
},
{
"radius",
"radii"
},
{
"photo",
"photos"
},
{
"piano",
"pianos"
},
{
"dwarf",
"dwarves"
},
{
"wharf",
"wharves"
},
{
"formula",
"formulae"
},
{
"moose",
"moose"
},
{
"phenomenon",
"phenomena"
}
};
// Token: 0x04000036 RID: 54
private string[] Sibilants = new string[]
{
"s",
"x",
"ch",
"sh",
"es",
"ss"
};
// Token: 0x04000037 RID: 55
private const string Vowels = "aeiouAEIOU";
// Token: 0x04000038 RID: 56
private const string Consonants = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ";
}
}