public override bool Equals(object obj) { XliffTranslation other = obj as XliffTranslation; if (other == null) { return(false); } return(this.LanguageCode == other.LanguageCode); }
public IRegistry[] AutoDetect() { var languages = new List <XliffTranslation>(); foreach (var lang in availableLanguages as IEnumerable) { string langCode = lang.GetType().GetField("LanguageCode", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(lang) as string; languages.Add(new XliffTranslation(langCode)); } var userLangName = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; var userLangName2 = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; XliffTranslation matchingLanguage = languages.FirstOrDefault(l => l.LanguageCode == userLangName) ?? languages.FirstOrDefault(l => l.LanguageCode.StartsWith(userLangName2, StringComparison.OrdinalIgnoreCase)) ?? languages.FirstOrDefault(l => l.LanguageCode == "en-US"); if (matchingLanguage == null) { throw new Exception("Fatal: No language available."); } languages.Remove(matchingLanguage); languages.Insert(0, matchingLanguage); return(languages.ToArray()); }