2

DateTime 让您根据当前的文化进行格式化。默认支持的文化是什么?

如果文化设置为美国英语,我想到的场景this.Date.Value.ToString("MMMM")将打印“January”,但如果文化是法语,则打印“Janvier”。此格式文档可以在MSDN 网站上找到,但没有给出可以翻译的文化范围。

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

4

5 回答 5

4
Afrikaans( afr-af )
Afrikaans (South Africa)( afr-af )
Albanian( sqi-sq )
Albanian (Albania)( sqi-sq )
Alsatian( gsw-gsw )
Alsatian (France)( gsw-gsw )
Amharic( amh-am )
Amharic (Ethiopia)( amh-am )
Arabic( ara-ar )
Arabic (Algeria)( ara-ar )
Arabic (Bahrain)( ara-ar )
Arabic (Egypt)( ara-ar )
Arabic (Iraq)( ara-ar )
Arabic (Jordan)( ara-ar )
Arabic (Kuwait)( ara-ar )
Arabic (Lebanon)( ara-ar )
Arabic (Libya)( ara-ar )
Arabic (Morocco)( ara-ar )
Arabic (Oman)( ara-ar )
Arabic (Qatar)( ara-ar )
Arabic (Saudi Arabia)( ara-ar )
Arabic (Syria)( ara-ar )
Arabic (Tunisia)( ara-ar )
Arabic (U.A.E.)( ara-ar )
Arabic (Yemen)( ara-ar )
Armenian( hye-hy )
Armenian (Armenia)( hye-hy )
Assamese( asm-as )
Assamese (India)( asm-as )
Azeri( aze-az )
Azeri (Cyrillic)( aze-az )
Azeri (Cyrillic, Azerbaijan)( aze-az )
Azeri (Latin)( aze-az )
Azeri (Latin, Azerbaijan)( aze-az )
Bashkir( bak-ba )
Bashkir (Russia)( bak-ba )
Basque( eus-eu )
Basque (Basque)( eus-eu )
Belarusian( bel-be )
Belarusian (Belarus)( bel-be )
Bengali( bng-bn )
Bengali (Bangladesh)( bng-bn )
Bengali (India)( bng-bn )
Bosnian( bsb-bs )
Bosnian (Cyrillic)( bsc-bs )
Bosnian (Cyrillic, Bosnia and Herzegovina)( bsc-bs )
Bosnian (Latin)( bsb-bs )
Bosnian (Latin, Bosnia and Herzegovina)( bsb-bs )
Breton( bre-br )
Breton (France)( bre-br )
Bulgarian( bul-bg )
Bulgarian (Bulgaria)( bul-bg )
Catalan( cat-ca )
Catalan (Catalan)( cat-ca )
Chinese( zho-zh )
Chinese (Simplified)( zho-zh )
Chinese (Simplified) Legacy( zho-zh )
Chinese (Simplified, PRC)( zho-zh )
Chinese (Simplified, Singapore)( zho-zh )
Chinese (Traditional)( zho-zh )
Chinese (Traditional) Legacy( zho-zh )
Chinese (Traditional, Hong Kong S.A.R.)( zho-zh )
Chinese (Traditional, Macao S.A.R.)( zho-zh )
Chinese (Traditional, Taiwan)( zho-zh )
Corsican( cos-co )
Corsican (France)( cos-co )
Croatian( hrv-hr )
Croatian (Croatia)( hrv-hr )
Croatian (Latin, Bosnia and Herzegovina)( hrb-hr )
Czech( ces-cs )
Czech (Czech Republic)( ces-cs )
Danish( dan-da )
Danish (Denmark)( dan-da )
Dari( prs-prs )
Dari (Afghanistan)( prs-prs )
Divehi( div-dv )
Divehi (Maldives)( div-dv )
Dutch( nld-nl )
Dutch (Belgium)( nld-nl )
Dutch (Netherlands)( nld-nl )
English( eng-en )
English (Australia)( eng-en )
English (Belize)( eng-en )
English (Canada)( eng-en )
English (Caribbean)( eng-en )
English (India)( eng-en )
English (Ireland)( eng-en )
English (Jamaica)( eng-en )
English (Malaysia)( eng-en )
English (New Zealand)( eng-en )
English (Republic of the Philippines)( eng-en )
English (Singapore)( eng-en )
English (South Africa)( eng-en )
English (Trinidad and Tobago)( eng-en )
English (United Kingdom)( eng-en )
English (United States)( eng-en )
English (Zimbabwe)( eng-en )
Estonian( est-et )
Estonian (Estonia)( est-et )
Faroese( fao-fo )
Faroese (Faroe Islands)( fao-fo )
Filipino( fil-fil )
Filipino (Philippines)( fil-fil )
Finnish( fin-fi )
Finnish (Finland)( fin-fi )
French( fra-fr )
French (Belgium)( fra-fr )
French (Canada)( fra-fr )
French (France)( fra-fr )
French (Luxembourg)( fra-fr )
French (Monaco)( fra-fr )
French (Switzerland)( fra-fr )
Frisian( fry-fy )
Frisian (Netherlands)( fry-fy )
Galician( glg-gl )
Galician (Galician)( glg-gl )
Georgian( kat-ka )
Georgian (Georgia)( kat-ka )
German( deu-de )
German (Austria)( deu-de )
German (Germany)( deu-de )
German (Liechtenstein)( deu-de )
German (Luxembourg)( deu-de )
German (Switzerland)( deu-de )
Greek( ell-el )
Greek (Greece)( ell-el )
Greenlandic( kal-kl )
Greenlandic (Greenland)( kal-kl )
Gujarati( guj-gu )
Gujarati (India)( guj-gu )
Hausa( hau-ha )
Hausa (Latin)( hau-ha )
Hausa (Latin, Nigeria)( hau-ha )
Hebrew( heb-he )
Hebrew (Israel)( heb-he )
Hindi( hin-hi )
Hindi (India)( hin-hi )
Hungarian( hun-hu )
Hungarian (Hungary)( hun-hu )
Icelandic( isl-is )
Icelandic (Iceland)( isl-is )
Igbo( ibo-ig )
Igbo (Nigeria)( ibo-ig )
Indonesian( ind-id )
Indonesian (Indonesia)( ind-id )
Inuktitut( iku-iu )
Inuktitut (Latin)( iku-iu )
Inuktitut (Latin, Canada)( iku-iu )
Inuktitut (Syllabics)( iku-iu )
Inuktitut (Syllabics, Canada)( iku-iu )
Invariant Language (Invariant Country)( ivl-iv )
Irish( gle-ga )
Irish (Ireland)( gle-ga )
isiXhosa( xho-xh )
isiXhosa (South Africa)( xho-xh )
isiZulu( zul-zu )
isiZulu (South Africa)( zul-zu )
Italian( ita-it )
Italian (Italy)( ita-it )
Italian (Switzerland)( ita-it )
Japanese( jpn-ja )
Japanese (Japan)( jpn-ja )
Kannada( kan-kn )
Kannada (India)( kan-kn )
Kazakh( kaz-kk )
Kazakh (Kazakhstan)( kaz-kk )
Khmer( khm-km )
Khmer (Cambodia)( khm-km )
K'iche( qut-qut )
K'iche (Guatemala)( qut-qut )
Kinyarwanda( kin-rw )
Kinyarwanda (Rwanda)( kin-rw )
Kiswahili( swa-sw )
Kiswahili (Kenya)( swa-sw )
Konkani( kok-kok )
Konkani (India)( kok-kok )
Korean( kor-ko )
Korean (Korea)( kor-ko )
Kyrgyz( kir-ky )
Kyrgyz (Kyrgyzstan)( kir-ky )
Lao( lao-lo )
Lao (Lao P.D.R.)( lao-lo )
Latvian( lav-lv )
Latvian (Latvia)( lav-lv )
Lithuanian( lit-lt )
Lithuanian (Lithuania)( lit-lt )
Lower Sorbian( dsb-dsb )
Lower Sorbian (Germany)( dsb-dsb )
Luxembourgish( ltz-lb )
Luxembourgish (Luxembourg)( ltz-lb )
Macedonian (Former Yugoslav Republic of Macedonia)( mkd-mk )
Macedonian (FYROM)( mkd-mk )
Malay( msa-ms )
Malay (Brunei Darussalam)( msa-ms )
Malay (Malaysia)( msa-ms )
Malayalam( mym-ml )
Malayalam (India)( mym-ml )
Maltese( mlt-mt )
Maltese (Malta)( mlt-mt )
Maori( mri-mi )
Maori (New Zealand)( mri-mi )
Mapudungun( arn-arn )
Mapudungun (Chile)( arn-arn )
Marathi( mar-mr )
Marathi (India)( mar-mr )
Mohawk( moh-moh )
Mohawk (Mohawk)( moh-moh )
Mongolian( mon-mn )
Mongolian (Cyrillic)( mon-mn )
Mongolian (Cyrillic, Mongolia)( mon-mn )
Mongolian (Traditional Mongolian)( mon-mn )
Mongolian (Traditional Mongolian, PRC)( mon-mn )
Nepali( nep-ne )
Nepali (Nepal)( nep-ne )
Norwegian( nob-nb )
Norwegian (Bokmål)( nob-nb )
Norwegian (Nynorsk)( nno-nn )
Norwegian, Bokmål (Norway)( nob-nb )
Norwegian, Nynorsk (Norway)( nno-nn )
Occitan( oci-oc )
Occitan (France)( oci-oc )
Oriya( ori-or )
Oriya (India)( ori-or )
Pashto( pus-ps )
Pashto (Afghanistan)( pus-ps )
Persian( fas-fa )
Persian( fas-fa )
Polish( pol-pl )
Polish (Poland)( pol-pl )
Portuguese( por-pt )
Portuguese (Brazil)( por-pt )
Portuguese (Portugal)( por-pt )
Punjabi( pan-pa )
Punjabi (India)( pan-pa )
Quechua( qub-quz )
Quechua (Bolivia)( qub-quz )
Quechua (Ecuador)( que-quz )
Quechua (Peru)( qup-quz )
Romanian( ron-ro )
Romanian (Romania)( ron-ro )
Romansh( roh-rm )
Romansh (Switzerland)( roh-rm )
Russian( rus-ru )
Russian (Russia)( rus-ru )
Sami (Inari)( smn-smn )
Sami (Lule)( smk-smj )
Sami (Northern)( sme-se )
Sami (Skolt)( sms-sms )
Sami (Southern)( smb-sma )
Sami, Inari (Finland)( smn-smn )
Sami, Lule (Norway)( smj-smj )
Sami, Lule (Sweden)( smk-smj )
Sami, Northern (Finland)( smg-se )
Sami, Northern (Norway)( sme-se )
Sami, Northern (Sweden)( smf-se )
Sami, Skolt (Finland)( sms-sms )
Sami, Southern (Norway)( sma-sma )
Sami, Southern (Sweden)( smb-sma )
Sanskrit( san-sa )
Sanskrit (India)( san-sa )
Scottish Gaelic( gla-gd )
Scottish Gaelic (United Kingdom)( gla-gd )
Serbian( srp-sr )
Serbian (Cyrillic)( srp-sr )
Serbian (Cyrillic, Bosnia and Herzegovina)( srn-sr )
Serbian (Cyrillic, Montenegro)( srp-sr )
Serbian (Cyrillic, Serbia and Montenegro (Former))( srp-sr )
Serbian (Cyrillic, Serbia)( srp-sr )
Serbian (Latin)( srp-sr )
Serbian (Latin, Bosnia and Herzegovina)( srs-sr )
Serbian (Latin, Montenegro)( srp-sr )
Serbian (Latin, Serbia and Montenegro (Former))( srp-sr )
Serbian (Latin, Serbia)( srp-sr )
Sesotho sa Leboa( nso-nso )
Sesotho sa Leboa (South Africa)( nso-nso )
Setswana( tsn-tn )
Setswana (South Africa)( tsn-tn )
Sinhala( sin-si )
Sinhala (Sri Lanka)( sin-si )
Slovak( slk-sk )
Slovak (Slovakia)( slk-sk )
Slovenian( slv-sl )
Slovenian (Slovenia)( slv-sl )
Spanish( spa-es )
Spanish (Argentina)( spa-es )
Spanish (Bolivarian Republic of Venezuela)( spa-es )
Spanish (Bolivia)( spa-es )
Spanish (Chile)( spa-es )
Spanish (Colombia)( spa-es )
Spanish (Costa Rica)( spa-es )
Spanish (Dominican Republic)( spa-es )
Spanish (Ecuador)( spa-es )
Spanish (El Salvador)( spa-es )
Spanish (Guatemala)( spa-es )
Spanish (Honduras)( spa-es )
Spanish (Mexico)( spa-es )
Spanish (Nicaragua)( spa-es )
Spanish (Panama)( spa-es )
Spanish (Paraguay)( spa-es )
Spanish (Peru)( spa-es )
Spanish (Puerto Rico)( spa-es )
Spanish (Spain)( spa-es )
Spanish (United States)( spa-es )
Spanish (Uruguay)( spa-es )
Swedish( swe-sv )
Swedish (Finland)( swe-sv )
Swedish (Sweden)( swe-sv )
Syriac( syr-syr )
Syriac (Syria)( syr-syr )
Tajik( tgk-tg )
Tajik (Cyrillic)( tgk-tg )
Tajik (Cyrillic, Tajikistan)( tgk-tg )
Tamazight( tzm-tzm )
Tamazight (Latin)( tzm-tzm )
Tamazight (Latin, Algeria)( tzm-tzm )
Tamil( tam-ta )
Tamil (India)( tam-ta )
Tatar( tat-tt )
Tatar (Russia)( tat-tt )
Telugu( tel-te )
Telugu (India)( tel-te )
Thai( tha-th )
Thai (Thailand)( tha-th )
Tibetan( bod-bo )
Tibetan (PRC)( bod-bo )
Turkish( tur-tr )
Turkish (Turkey)( tur-tr )
Turkmen( tuk-tk )
Turkmen (Turkmenistan)( tuk-tk )
Ukrainian( ukr-uk )
Ukrainian (Ukraine)( ukr-uk )
Upper Sorbian( hsb-hsb )
Upper Sorbian (Germany)( hsb-hsb )
Urdu( urd-ur )
Urdu (Islamic Republic of Pakistan)( urd-ur )
Uyghur( uig-ug )
Uyghur (PRC)( uig-ug )
Uzbek( uzb-uz )
Uzbek (Cyrillic)( uzb-uz )
Uzbek (Cyrillic, Uzbekistan)( uzb-uz )
Uzbek (Latin)( uzb-uz )
Uzbek (Latin, Uzbekistan)( uzb-uz )
Vietnamese( vie-vi )
Vietnamese (Vietnam)( vie-vi )
Welsh( cym-cy )
Welsh (United Kingdom)( cym-cy )
Wolof( wol-wo )
Wolof (Senegal)( wol-wo )
Yakut( sah-sah )
Yakut (Russia)( sah-sah )
Yi( iii-ii )
Yi (PRC)( iii-ii )
Yoruba( yor-yo )
Yoruba (Nigeria)( yor-yo )
于 2012-07-25T13:17:39.460 回答
2

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

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 个。

于 2012-07-25T13:16:08.677 回答
1

我会想象操作系统支持的所有语言(考虑到信息的来源)。

这是OS 支持的所有默认语言的列表。

于 2012-07-25T13:08:18.800 回答
1

支持的文化集将是已安装在盒子上的自定义文化集加上预定义的文化集(对于 .Net 3.5 及更低版本或 Vista 及更低版本,这是一个固定集,但对于 .Net 4 及更高版本Win7 及更高版本,这是运行它的操作系统的预定义文化)。

如果不支持某种语言,您可以创建自定义文化。这确实需要管理员权限才能安装。

于 2012-07-25T16:25:06.427 回答
0

你可以像这样改变你的文化:

将 CurrentThread.CurrentCulture 设置为新的文化,例如设置为法语:

System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("fr-FR");
System.Threading.Thread.CurrentThread.CurrentCulture = ci;

在您的日期格式之后,月份名称将是法语。

您可以从这些文化中进行选择

于 2012-07-25T13:13:28.840 回答