I can get the list of country names using below code, (copied from somewhere i can't remember)
My question is, can i get the list of countries in other languages such as Thai ?
/// <summary>
/// method for generating a country list, say for populating
/// a ComboBox, with country options. We return the
/// values in a Generic List<T>
/// </summary>
/// <returns></returns>
public static List<string> GetCountryList()
{
//create a new Generic list to hold the country names returned
List<string> cultureList = new List<string>();
//create an array of CultureInfo to hold all the cultures found, these include the users local cluture, and all the
//cultures installed with the .Net Framework
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
//loop through all the cultures found
foreach (CultureInfo culture in cultures)
{
//pass the current culture's Locale ID (http://msdn.microsoft.com/en-us/library/0h88fahh.aspx)
//to the RegionInfo contructor to gain access to the information for that culture
RegionInfo region = new RegionInfo(culture.LCID);
//make sure out generic list doesnt already
//contain this country
if (!(cultureList.Contains(region.EnglishName)))
//not there so add the EnglishName (http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.englishname.aspx)
//value to our generic list
cultureList.Add(region.EnglishName);
}
return cultureList;
}
Most countries of the world have different names in different languages. Some countries have also undergone name changes for political or other reasons.
Germany is one of several countries that have completely different names in different languages. In French, Germany is Allemagne; in German, it's Deutschland; in Finnish, it's Saksa; in Danish, it's Tyskland; in Polish, it's Niemcy.
This library provides the full list of ISO 639-1 languages and the full list of ISO 3166-1 countries. The library supports 89 languages (the full list is available by querying the library API itself) and it is designed to be easy to import and use.
http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.displayname.aspx
The DisplayName property displays the country/region name in the language of the localized version of .NET Framework. For example, the DisplayName property displays the country/region in English on the English version of the .NET Framework, and in Spanish on the Spanish version of the .NET Framework.
So it looks like there's no list of country names in each language in the .NET Framework, only in the language that the installed .NET Framework is.
Either use DisplayName
(gives you the name in the current Framework Culture) or NativeName
(gives you the name in the native culture) instead of EnglishName
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With