The CultureInfo class provides culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. This class also provides access to culture-specific instances of DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo. These objects contain the information required for culture-specific operations, such as casing, formatting dates and numbers, and comparing strings.
The members of the String class either directly or indirectly use this class to obtain information about the default culture.
Note: |
|---|
CultureInfo objects other than CultureInfo..::.InvariantCulture retrieve their data from the operating system. As a result, the values of individual CultureInfo properties may differ not only by operating system, but also within versions of the same operating system. |
Culture Names and Identifiers
The CultureInfo class specifies a unique name for each culture, based on RFC 4646. The name is a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code associated with a country or region. The format for the culture name is "languagecode-country/regioncode", where languagecode is the language code and country/regioncode is the subculture code. Examples include "ja-JP" for Japanese (Japan) and "en-US" for English (United States). In cases where a two-letter language code is not available, a three-letter code derived from ISO 639-2 is used.
Some culture names also specify an ISO 15924 script. For example, "-Cyrl" specifies the Cyrillic script and "-Latn" specifies the Latin script. A culture name including a script is rendered using the pattern "languagecode-scripttag-country/regioncode". An example of this type of culture name is "uz-Cyrl-UZ" for Uzbek (Uzbekistan, Cyrillic).
A neutral culture (a culture defined by a language with no specific country/region) is specified by the two-digit lowercase language code only. For example, "fr" specifies the neutral culture for French, and "de" specifies the neutral culture for German.
Note: |
|---|
There are two culture names that contradict this rule. The cultures "zh-Hans" (Simplified Chinese) and "zh-Hant" (Traditional Chinese) are neutral cultures. |
The following table lists the predefined culture names that are recognized by the .NET Framework for Silverlight and that can be used when instantiating a CultureInfo object. However, because the .NET Framework for Silverlight retrieves culture information from the operating system, the availability of cultural information may vary depending on the platform and operating system version.
Culture/language name | Culture |
|---|
"" (empty string) | Invariant culture |
af | Afrikaans |
af-ZA | Afrikaans (South Africa) |
sq | Albanian |
sq-AL | Albanian (Albania) |
ar | Arabic |
ar-DZ | Arabic (Algeria) |
ar-BH | Arabic (Bahrain) |
ar-EG | Arabic (Egypt) |
ar-IQ | Arabic (Iraq) |
ar-JO | Arabic (Jordan) |
ar-KW | Arabic (Kuwait) |
ar-LB | Arabic (Lebanon) |
ar-LY | Arabic (Libya) |
ar-MA | Arabic (Morocco) |
ar-OM | Arabic (Oman) |
ar-QA | Arabic (Qatar) |
ar-SA | Arabic (Saudi Arabia) |
ar-SY | Arabic (Syria) |
ar-TN | Arabic (Tunisia) |
ar-AE | Arabic (U.A.E.) |
ar-YE | Arabic (Yemen) |
hy | Armenian |
hy-AM | Armenian (Armenia) |
az | Azeri |
az-Cyrl-AZ | Azeri (Azerbaijan, Cyrillic) |
az-Latn-AZ | Azeri (Azerbaijan, Latin) |
eu | Basque |
eu-ES | Basque (Basque) |
be | Belarusian |
be-BY | Belarusian (Belarus) |
bg | Bulgarian |
bg-BG | Bulgarian (Bulgaria) |
ca | Catalan |
ca-ES | Catalan (Catalan) |
zh-HK | Chinese (Hong Kong SAR, PRC) |
zh-MO | Chinese (Macao SAR) |
zh-CN | Chinese (PRC) |
zh-Hans | Chinese (Simplified) |
zh-SG | Chinese (Singapore) |
zh-TW | Chinese (Taiwan) |
zh-Hant | Chinese (Traditional) |
hr | Croatian |
hr-BA | Croatian (Bosnia and Herzegovina) |
hr-HR | Croatian (Croatia) |
cs | Czech |
cs-CZ | Czech (Czech Republic) |
da | Danish |
da-DK | Danish (Denmark) |
dv | Divehi |
dv-MV | Divehi (Maldives) |
nl | Dutch |
nl-BE | Dutch (Belgium) |
nl-NL | Dutch (Netherlands) |
en | English |
en-AU | English (Australia) |
en-BZ | English (Belize) |
en-CA | English (Canada) |
en-029 | English (Caribbean) |
en-IE | English (Ireland) |
en-JM | English (Jamaica) |
en-NZ | English (New Zealand) |
en-PH | English (Philippines) |
en-ZA | English (South Africa |
en-TT | English (Trinidad and Tobago) |
en-GB | English (United Kingdom) |
en-US | English (United States) |
en-ZW | English (Zimbabwe) |
et | Estonian |
et-EE | Estonian (Estonia) |
fo | Faroese |
fo-FO | Faroese (Faroe Islands) |
fa | Farsi |
fa-IR | Farsi (Iran) |
fi | Finnish |
fi-FI | Finnish (Finland) |
fr | French |
fr-BE | French (Belgium) |
fr-CA | French (Canada) |
fr-FR | French (France) |
fr-LU | French (Luxembourg) |
fr-MC | French (Monaco) |
fr-CH | French (Switzerland) |
gl | Galician |
gl-ES | Galician (Spain) |
ka | Georgian |
ka-GE | Georgian (Georgia) |
de | German |
de-AT | German (Austria) |
de-DE | German (Germany) |
de-DE_phoneb | German (Germany, phone book sort) |
de-LI | German (Liechtenstein) |
de-LU | German (Luxembourg) |
de-CH | German (Switzerland) |
el | Greek |
el-GR | Greek (Greece) |
gu | Gujarati |
gu-IN | Gujarati (India) |
he | Hebrew |
he-IL | Hebrew (Israel) |
hi | Hindi |
hi-IN | Hindi (India) |
hu | Hungarian |
hu-HU | Hungarian (Hungary) |
is | Icelandic |
is-IS | Icelandic (Iceland) |
id | Indonesian |
id-ID | Indonesian (Indonesia) |
it | Italian |
it-IT | Italian (Italy) |
it-CH | Italian (Switzerland) |
ja | Japanese |
ja-JP | Japanese (Japan) |
kn | Kannada |
kn-IN | Kannada (India) |
kk | Kazakh |
kk-KZ | Kazakh (Kazakhstan) |
kok | Konkani |
kok-IN | Konkani (India) |
ko | Korean |
ko-KR | Korean (Korea) |
ky | Kyrgyz |
ky-KG | Kyrgyz (Kyrgyzstan) |
lv | Latvian |
lv-LV | Latvian (Latvia) |
lt | Lithuanian |
lt-LT | Lithuanian (Lithuania) |
mk | Macedonian |
mk-MK | Macedonian (Macedonia, FYROM) |
ms | Malay |
ms-BN | Malay (Brunei Darussalam) |
ms-MY | Malay (Malaysia) |
mr | Marathi |
mr-IN | Marathi (India) |
mn | Mongolian |
mn-MN | Mongolian (Mongolia) |
no | Norwegian |
nb-NO | Norwegian (Bokmål, Norway) |
nn-NO | Norwegian (Nynorsk, Norway) |
pl | Polish |
pl-PL | Polish (Poland) |
pt | Portuguese |
pt-BR | Portuguese (Brazil) |
pt-PT | Portuguese (Portugal) |
pa | Punjabi |
pa-IN | Punjabi (India) |
ro | Romanian |
ro-RO | Romanian (Romania) |
ru | Russian |
ru-RU | Russian (Russia) |
sa | Sanskrit |
sa-IN | Sanskrit (India) |
sr-Cyrl-CS | Serbian (Serbia, Cyrillic) |
sr-Latn-CS | Serbian (Serbia, Latin) |
sk | Slovak |
sk-SK | Slovak (Slovakia) |
sl | Slovenian |
sl-SI | Slovenian (Slovenia) |
es | Spanish |
es-AR | Spanish (Argentina) |
es-BO | Spanish (Bolivia) |
es-CL | Spanish (Chile) |
es-CO | Spanish (Colombia) |
es-CR | Spanish (Costa Rica) |
es-DO | Spanish (Dominican Republic) |
es-EC | Spanish (Ecuador) |
es-SV | Spanish (El Salvador) |
es-GT | Spanish (Guatemala) |
es-HN | Spanish (Honduras) |
es-MX | Spanish (Mexico) |
es-NI | Spanish (Nicaragua) |
es-PA | Spanish (Panama) |
es-PY | Spanish (Paraguay) |
es-PE | Spanish (Peru) |
es-PR | Spanish (Puerto Rico) |
es-ES | Spanish (Spain) |
es-ES_tradnl | Span (Span, Traditional Sort) |
es-UY | Spanish (Uruguay) |
es-VE | Spanish (Venezuela) |
sw | Swahili |
sw-KE | Swahili (Kenya) |
sv | Swedish |
sv-FI | Swedish (Finland) |
sv-SE | Swedish (Sweden) |
syr | Syriac |
syr-SY | Syriac (Syria) |
ta | Tamil |
ta-IN | Tamil (India) |
tt | Tatar |
tt-RU | Tatar (Russia) |
te | Telugu |
te-IN | Telugu (India) |
th | Thai |
th-TH | Thai (Thailand) |
tr | Turkish |
tr-TR | Turkish (Turkey) |
uk | Ukrainian |
uk-UA | Ukrainian (Ukraine) |
ur | Urdu |
ur-PK | Urdu (Pakistan) |
uz | Uzbek |
uz-Cyrl-UZ | Uzbek (Uzbekistan, Cyrillic) |
uz-Latn-UZ | Uzbek (Uzbekistan, Latin) |
vi | Vietnamese |
vi-VN | Vietnamese (Vietnam) |
Several distinct names are closely associated with a culture, notably the names associated with the following class members:
CultureInfo..::.ToString
Typically, this is a "normalized" version of the string that is passed to the CultureInfo class constructor. Its language component is always lowercased and its country/region component is always uppercased.
CultureInfo..::.Name
This name represents the language and country/region component of the CultureInfo object together with a script, if one is present. It does not include sort order information if the CultureInfo object was instantiated with a string that defines a particular sort order.
CompareInfo..::.Name
This name represents the language and country/region component together with a component script, if one is present, and an indication of the sort order, if it is relevant.
Invariant, Neutral, and Specific Cultures
The cultures are generally grouped into three sets: invariant cultures, neutral cultures, and specific cultures.
An invariant culture is culture-insensitive. Your application specifies the invariant culture by name using an empty string ("") or by its identifier. InvariantCulture defines an instance of the invariant culture. It is associated with the English language but not with any country/region. It is used in almost any method in the System.Globalization namespace that requires a culture.
A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, "fr" is a neutral culture and "fr-FR" is a specific culture. Note that "zh-Hans" (Simplified Chinese) and "zh-Hant" (Traditional Chinese) are neutral cultures.
Creating an instance of a CompareInfo class for a neutral culture is not recommended because the data it contains is arbitrary. To display and sort data, specify both the language and region.
The defined cultures have a hierarchy in which the parent of a specific culture is a neutral culture and the parent of a neutral culture is the invariant culture. The Parent property contains the neutral culture associated with a specific culture. Custom cultures should define the Parent property in conformance with this pattern.
If DateTimeFormatInfo..::.Calendar is the TaiwanCalendar but the Thread..::.CurrentCulture is not "zh-TW", then DateTimeFormatInfo..::.GetEraName and DateTimeFormatInfo..::.GetAbbreviatedEraName return an empty string ("").
Custom Cultures
When preparing software to handle custom cultures, consider the following:
Custom cultures can have values that exceed the ranges of the Microsoft-shipped cultures. For example, some cultures have unusually long month names, unexpected date or time formats, or other unusual data.
Respect the user's culture data values; for example, the user might want a 24-hour clock or a yyyyMMdd date format.
Remember that custom cultures override default values. Therefore, you cannot consider culture data to be stable. Country names, date formats, and spellings will probably change in the future.
Dynamic Culture Data
Except for the invariant culture, culture data is dynamic. This is true even for the predefined cultures. For example, countries or regions adopt new currencies, change their spellings of words, or change their preferred calendar, and culture definitions change to track this. Custom cultures are subject to change without notice, and any specific culture might be overridden by a custom replacement culture. An individual user can also override cultural preferences. Applications should always obtain culture data at run time.
Implemented Interfaces
This class implements IFormatProvider to supply formatting information to applications.