获得国家名单中除英语以外的其他语言 [英] Get country list in other languages besides english

查看:179
本文介绍了获得国家名单中除英语以外的其他语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用下面code国名的列表,(从什么地方我不记得复制)

我的问题是,我可以在其他语言的国家名单,如泰国?

  ///<总结>
    ///方法产生的国家名单,说来填充
    ///一个组合框,与国家的选择。我们返回
    在泛型列表&LT ///值; T>
    ///< /总结>
    ///<返回>< /回报>
    公共静态列表<字符串> GetCountryList()
    {
        //创建一个新的通用列表来保存返回的国名
        名单<字符串> cultureList =新的名单,其中,串>();

        //创建的CultureInfo的一个数组来保存找到的所有的文化,这其中就包括用户当地的紫色非硫,和所有的
        与.NET Framework安装//文化
        的CultureInfo []文化= CultureInfo.GetCultures(CultureTypes.AllCultures&安培;〜CultureTypes.NeutralCultures);

        //在所有的文化中环发现
        的foreach(在文化的CultureInfo文化)
        {
            //传递当前文化的区域设置ID(http://msdn.microsoft.com/en-us/library/0h88fahh.aspx)
            //到RegionInfo构造器来访问的信息,该培养
            RegionInfo地区=新RegionInfo(culture.LCID);

            //确保了泛型列表犯规已经
            //包含这个国家
            如果(!(cultureList.Contains(region.EnglishName)))
                //不存在这样添加中文名(http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.englishname.aspx)
                //价值,我们的泛型列表
                cultureList.Add(region.EnglishName);
        }
        返回cultureList;
    }
 

解决方案
  

<一个href="http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.displayname.aspx">http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.displayname.aspx

     

的显示名称属性显示在.NET Framework的本地化版本的语言的国家/地区名称。例如,显示名称属性显示在.NET Framework

西班牙语版本的.NET Framework的英文版本的国家/地区的英文,,并在西班牙

因此​​,它看起来像有国名的.NET Framework中的每种语言没有列表,只有在已安装.NET Framework是语言。

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;
    }

解决方案

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.

这篇关于获得国家名单中除英语以外的其他语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆