Why is CultureInfo.DisplayName in Sami all of a sudden? I use it to display a list of country names. Not a good idea perhaps but it worked until recently and I'm quite sure it was in Swedish (I guess it could have been English.)
MSDN says
This property represents the localized name from the .NET Framework version. For example, if the .NET Framework English version is installed, the property returns "English (United States)" for the en-US culture name. If the .NET Framework Spanish version is installed, regardless of the language that the system is set to display, the culture name is displayed in Spanish and the property for en-US returns "Ingles (Estados Unidos)".
But I'm quite sure I don't have Sami version of the framework installed.
My web-config has:
<globalization
culture="sv-SE"
uiCulture="sv-SE"/>
Addition: The code
public static IEnumerable<KeyValuePair<string, string>> CountryList
{
get
{
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("sv-SE");
Thread.CurrentThread.CurrentUICulture = new
CultureInfo("sv-SE");
var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
/*Array.Sort(countries.Select(
x => Regex.Match(x.DisplayName, "\\(([\\w- ]+)\\)").ToString()).ToArray(),
countries);
*/
SortedDictionary<string, CultureInfo> d = new SortedDictionary<string, CultureInfo>();
foreach (CultureInfo cultureInfo in cultures)
{
string key = Regex.Match(cultureInfo.DisplayName, "\\(([\\w- ]+)\\)").ToString();
if (!d.ContainsKey(key))
d.Add(key, cultureInfo);
}
var countries = d
.Where(x => Regex.Match(x.Value.DisplayName, "\\([A-ZÅÄÖ]").Success)
.Select(
x => new KeyValuePair<string, string>(
Regex.Match(x.Value.Name, "-(\\w+)").Groups[1].ToString(),
Regex.Match(x.Value.DisplayName, "\\(([\\w- ]+)\\)").Groups[1].ToString()
));
return countries;
}
}