如何获取.Net中的语言环境列表 [英] How to get list of locales in .Net

查看:80
本文介绍了如何获取.Net中的语言环境列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为用户提供选择文本文件区域设置的选项.

I would like to give user option to select text file locale.

.net中是否有一些类保留可用语言环境列表?

Is there some class in .net that keeps list of available locales?

现在,我正计划从MSDN页面创建自己的列表类:语言标识符常量和字符串,但是如果.net中已经存在某些内容,那就更好了.

Now, I am planning to make my own list class from MSDN page: Language Identifier Constants and Strings, but it would be nicer if there is something already in .net.

此处是有关 CultureInfo.GetCultures方法的MSDN文章杰里米(Jeremy)在回答中写道.还有一些代码示例.

Here is MSDN article on CultureInfo.GetCultures method that Jeremy wrote in his answer. There are also code examples.

推荐答案

您希望使用针对每个语言环境循环".

You'd want like a 'for each locale loop'.

    Dim info As CultureInfo
    For Each info In CultureInfo.GetCultures(CultureTypes.AllCultures)

        ListBox1.Items.Add(info.EnglishName)
    Next

半秒钟就将语言环境列表转储到Listbox1

Takes like half a second to dump a list of locales into the Listbox1

然后,您可以通过多种方式引用信息",例如:

Then you can reference 'info' in various ways such as:

    info.NumberFormat
    info.DateTimeFormat

获取该区域设置日期中的今天日期:

Get todays date in that locales date:

        If Not info.IsNeutralCulture Then
            Dim dateNow As DateTime = DateTime.Now
            ListBox1.Items.Add(dateNow.ToString("d", info.DateTimeFormat).ToString)
        End If

这篇关于如何获取.Net中的语言环境列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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