DateTime supported language for formatting?

杀马特。学长 韩版系。学妹 提交于 2020-01-14 01:56:38

问题


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

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?


回答1:


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

Here's a demo: http://ideone.com/9CUjK

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




回答2:


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 )



回答3:


I would imagine all languages that the OS supports (considering that is where the information comes from).

Here is a list of all default supported languages by OS.




回答4:


The set of supported cultures will be the set of custom cultures that have been installed on the box plus the set of predefined cultures (for .Net 3.5 and below or Vista and below this is a fixed set, but for .Net 4 and above on Win7 and above, this is predefined cultures for the OS that it is running on).

If a language isn't supported, you can create a custom culture. This does require admin privilege to install.




回答5:


You can change your culture like this:

Set the CurrentThread.CurrentCulture to a new culture, e.g. to set to French:

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

and after your date format, and month name will be french.

You can choose from these Cultures



来源:https://stackoverflow.com/questions/11650362/datetime-supported-language-for-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!