日期时间支持的语言格式? [英] DateTime supported language for formatting?

查看:125
本文介绍了日期时间支持的语言格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

日期时间让你的格式取决于当前的文化。什么是文化默认支持?

DateTime let you format depending of the current culture. What are the culture supported by default?

记住使用 this.Date.Value.ToString(MMMM)的情况下我有这将打印月,如果区域性设置为英语(美国)但将打印维耶如果文化是法语-CA。此格式的文件可以在<一个发现href="http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.monthnames.aspx"相对=nofollow> MSDN网站,但并没有给文化的范围,这个可以翻译。

The scenario I have in mind use this.Date.Value.ToString("MMMM") which will print "January" if the culture is set to english-us but will print "Janvier" if the culture is in french-ca. This formatting documentation can be found at MSDN website but doesn't give the scope of culture this one can translate.

我想知道是什么语言的支持,如果语言不,我有哪些选择?

I would like to know what languages are supported and if a language is not, what are my options?

推荐答案

您可以使用的 CultureInfo.GetCultures 让所有支持的文化。

You can use CultureInfo.GetCultures to get all supported cultures.

CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
string allTranslatedJanuaries = 
    string.Join(Environment.NewLine, cultures.Select(c =>
        String.Format("{0}: {1}", c.EnglishName, c.DateTimeFormat.GetMonthName(1))));

下面是一个演示: http://ideone.com/9CUjK

在我的服务器上安装了352文化,在ideone只有112。

On my server 352 cultures are installed, upon ideone only 112.

这篇关于日期时间支持的语言格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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