public void GetBestLanguageName_ForXYZ_FindsXYZ()
 {
     var sut = new LanguageLookupModel();
     string name;
     Assert.That(sut.GetBestLanguageName("xyz", out name), Is.False);
     Assert.That(name, Is.EqualTo("xyz"));
 }
 public void GetBestLanguageName_ForFR_FindsFrench()
 {
     var sut = new LanguageLookupModel();
     string name;
     Assert.That(sut.GetBestLanguageName("fr", out name), Is.True);
     Assert.That(name, Is.EqualTo("French"));
 }
 public void GetBestLanguageName_ForARA_FindsArabic()
 {
     var sut = new LanguageLookupModel();
     string name;
     Assert.That(sut.GetBestLanguageName("ara", out name), Is.True);
     Assert.That(name, Is.EqualTo("Arabic"));
 }
 public LanguageLookupControl()
 {
     InitializeComponent();
     _model = new LanguageLookupModel();
 }
		public LanguageLookupControl()
		{
			InitializeComponent();
			_model = new LanguageLookupModel();
		}
 /// <summary>
 /// Add to the dictionary which maps original to Localized strings an entry for any language code that doesn't already
 /// have one. We have localizations for a few major languages that map e.g. de->German/Deutsch/etc, so they are functioning
 /// not just to localize but to expand from a language code to an actual name. For any other languages where we don't
 /// have localization information, we'd like to at least expand the cryptic code into a name. This method does that.
 /// </summary>
 /// <param name="xmlDocument"></param>
 /// <param name="mapOriginalToLocalized"></param>
 internal static void AddLanguagesUsedInPage(XmlDocument xmlDocument, Dictionary<string, string> mapOriginalToLocalized)
 {
     var langs = xmlDocument.SafeSelectNodes("//*[@lang]").Cast<XmlElement>()
         .Select(e => e.Attributes["lang"].Value)
         .Distinct()
         .Where(lang => !mapOriginalToLocalized.ContainsKey(lang))
         .ToList();
     if (langs.Any())
     {
         // We don't have a localization for these languages, but we can at least try to give them a name
         var lookup = new LanguageLookupModel(); // < 1ms
         foreach (var lang in langs) // may include things like empty string, z, *, but this is harmless as they are not language codes.
         {
             string match;
             if (lookup.GetBestLanguageName(lang, out match)) // some better name found
                 mapOriginalToLocalized[lang] = match;
         }
     }
 }