Get country list in other languages besides english

后端 未结 3 1655
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-19 09:21

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 a

相关标签:
3条回答
  • 2021-02-19 09:34

    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.

    0 讨论(0)
  • 2021-02-19 09:35

    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.

    0 讨论(0)
  • 2021-02-19 09:56

    Pretty late answer:

    In my application the user can select a language (among languages that the application supports) and in the UI I need to display country names in the selected language.

    I found that NuGet package IsoNames fullfills that purpose. It provides method

    IsoNames.CountryNames.GetName(CultureInfo culture, string countrycode);
    

    and thus overcomes the restrictions implied with the DisplayName.

    0 讨论(0)
提交回复
热议问题