public bool LoadFromXmlResource(string langFolder) { try { if (!Directory.Exists(langFolder)) { return(false); } if (int.TryParse(SerializerHelper.LoadText(Path.Combine(langFolder, CurrentLangFile)), out int landId)) { Langs.Clear(); Words.Clear(); foreach (string lang in Directory.GetDirectories(langFolder)) { string name = new DirectoryInfo(lang).Name; if (int.TryParse(name.Substring(0, name.IndexOf('.')), out int id)) { name = name.Substring(name.IndexOf('.') + 1); Langs.Add(new Lang { Id = id, Name = name }); string text = SerializerHelper.LoadText(Path.Combine(lang, WordsFile)); while (!string.IsNullOrEmpty(text)) { if (text[0] == '<') { string key = text.Substring(1, text.IndexOf('>') - 1); string value = text.Substring(text.IndexOf('>') + 1, text.IndexOf($"</{key}>") - $"</{key}>".Length + 1); Word word = Words.FirstOrDefault(w => w.Key == key); if (word == null) { word = new Word { Key = key, Values = new Dictionary <int, string>() }; Words.Add(word); } if (word.Values.ContainsKey(id)) { word.Values[id] = value; } else { word.Values.Add(id, value); } text = text.Substring(key.Length * 2 + value.Length + 5).TrimStart('\r', '\n'); } } } } CurrentLang = Langs.FirstOrDefault(l => l.Id == landId) ?? Langs.FirstOrDefault(); return(true); } } catch (Exception ex) { Logger.Log(ex); } return(false); }