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;
}
}
}