Question

Is it possible to retrieve a localized name of a country in .NET?

The RegionInfo class has only the EnglishName, DisplayName and NativeName - but it doesn't seem to be possible to get for example the local Danish name for "Austria" which is "Østrig". They will always return the English name, no matter which Culture or UICulture the thread runs with.

Is there a technique I can use, or will I have to create a data store for that?

Was it helpful?

Solution

The localized names are only available if the framework has resources in the required language. Therefore, you need to install the language pack before DisplayName returns the wanted names (with the correct culture set in the application, of course).

Download the danish 3.5 SP1 language pack here (many other languages can be chosen as well).

OTHER TIPS

Guys, you're completely misunderstood the MSDN statement:

The DisplayName property displays the country/region name in the language of the localized version of .NET Framework.

So you need to implement your own localization for country names.

According to the MSDN docs, RegionInfo.DisplayName should get the localised (in your case, Danish) name of the country. Given that it's still returning the English version for you, my suspicions are that you simply need to configure the locale when you (re)install the .NET Framework. Let me know if that does the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top