DateTime lingua supportata per la formattazione?

DateTime ti consente di formattare in base alla cultura corrente. Quali sono le culture supportate di default?

Lo scenario che ho in mente usa this.Date.Value.ToString("MMMM") che stamperà “Gennaio” se la cultura è impostata su inglese-noi ma stamperà “Janvier” se la cultura è in francese-ca. Questa documentazione di formattazione può essere trovata sul sito Web MSDN ma non offre l’ambito della cultura che questo può tradurre.

Mi piacerebbe sapere quali lingue sono supportate e se una lingua non lo è, quali sono le mie opzioni?

Puoi utilizzare CultureInfo.GetCultures per ottenere tutte le culture supportate.

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

Ecco una demo: http://ideone.com/9CUjK

Sul mio server sono installate 352 culture, su ideone solo 112.

 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 (UAE)( 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 SAR)( zho-zh ) Chinese (Traditional, Macao SAR)( 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 PDR)( 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 ) 

Immaginerei tutte le lingue supportate dal sistema operativo (considerando che è da lì che provengono le informazioni).

Ecco un elenco di tutte le lingue supportate predefinite dal sistema operativo .

Il set di culture supportate sarà l’insieme di culture personalizzate che sono state installate sulla scatola più il set di culture predefinite (per .Net 3.5 e versioni successive o Vista e sotto questo è un set fisso, ma per .Net 4 e versioni successive su Win7 e versioni successive, sono culture predefinite per il sistema operativo su cui è in esecuzione).

Se una lingua non è supportata, puoi creare una cultura personalizzata. Questo richiede il privilegio di amministratore da installare.

Puoi cambiare la tua cultura in questo modo:

Imposta CurrentThread.CurrentCulture su una nuova cultura, ad esempio per impostare il francese:

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

e dopo il formato della data e il nome del mese sarà francese.

Puoi scegliere tra queste Culture