private static void Parse()
{
_dictionary = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();
_availableLanguages = new SortedSet <string>();
try
{
var document = new XmlDocument();
document.LoadXml(ResourceArchive.GetTranslationsStream().ReadAllContentsAsString());
foreach (var categoryNode in
document.SelectNodes("/translations/category")?.Cast <XmlNode>() ?? new XmlNode[0]
)
{
var categoryId = categoryNode?.Attributes?["id"]?.Value ?? "";
if (!_dictionary.ContainsKey(categoryId))
{
_dictionary[categoryId] = new Dictionary <string, Dictionary <string, string> >();
}
foreach (var textNode in categoryNode?.SelectNodes("text")?.Cast <XmlNode>() ?? new XmlNode[0])
{
var textId = textNode?.Attributes?["id"]?.Value ?? "";
if (!_dictionary[categoryId].ContainsKey(textId))
{
_dictionary[categoryId][textId] = new Dictionary <string, string>();
}
foreach (var translationNode in textNode?.SelectNodes("translation")?.Cast <XmlNode>() ??
new XmlNode[0])
{
var langId = translationNode?.Attributes["lang"].Value;
var text = translationNode.InnerText;
if (DefaultLanguage == null)
{
DefaultLanguage = langId;
}
if (langId != "xx")
{
AvailableLanguages.Add(langId);
}
//Console.WriteLine("{0}.{1}.{2} = {3}", CategoryId, TextId, LangId, Text);
_dictionary[categoryId][textId][langId] = text;
}
}
}
}
catch (Exception exception)
{
Console.Error.WriteLine(exception);
}
}