views:

344

answers:

3

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?

A: 

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.

Noldorin
Well, it returns the English name...
JacobE
Sounds like it's actuall NativeName you want: http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.nativename.aspx
Greg Beech
All the different *Name properties returns the English name - always - it seems to be indifferent to the current thread culture.
JacobE
@JacobE: In that case, I suspect it's because you have the English version of the .NET framework installed. If you install the Danish-language version, DisplayName should return exactly what you want.
Noldorin
@Noldorin: ... and you set the current locale appropriately.
Richard
@Richard: Yeah, exactly. I believe it's the same installation package, he just needs to select the Danish locale on setup.
Noldorin
Thanks guys, but I can't have 8 different .NET framework installations for the 8-language website I'm working on... :) I'll need to make an own implementation.
JacobE
Fair enough. In that case, yeah, you'll need to generate your own dataset.
Noldorin
+2  A: 

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.

balint
No need to implement it yourself, just make sure that the framework has the recources in the required language.
Lucero
well, 35.6 MB - 73.4 MB* for ~120 strings seems a bit odd for me :)
balint
+5  A: 

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).

Lucero