Describing a Culture with LDML Data
When you save a culture with System.Globalization.CultureAndRegionInfoBuilder.Save(System.String), the resulting XML representation of the CultureAndRegionInfoBuilder object follows the format of Locale Data Markup Language (LDML) version 1.1. The CreateFromLdml method is the inverse of Save, and loads from this XML file.
Most of the meaningful data that describes a culture is contained in special elements within the XML file. LDML special elements allow for product-specific annotation and data.
The .NET Framework uses the special element as a place to put data drawn from the msLocale schema, https://schemas.microsoft.com/globalization/2005/carib/ldml. (As is normal for a schema, that URI provides a unique name for the schema, but is not the URL of an actual document.) Most of the relevant XML elements correspond to properties (or to values returned by methods) of the classes that describe a culture, such as CultureAndRegionInfoBuilder and CultureInfo. A small number of elements are specific to Windows rather than to .NET, and are not included as properties of CultureAndRegionInfoBuilder.
For more information about the LDML standard, see Unicode Technical Standard #35, "Locale Data Markup Language (LDML)," at the Unicode home site.
Windows-only elements
Several elements below are described as Windows-only. That means they are relevant for unmanaged code on the Microsoft Windows operating system, but no relevant for .NET Framework. If you create an LDML file outside of .NET Framework, then use .NET Framework to register it, it becomes available to Windows as well as to .NET Framework, so these properties may be relevant. Also, inside .NET Framework, if you start from an existing culture definition, then modify it and save it as a custom culture (either a replacement culture or a supplemental culture), these Windows-only elements will pass through intact from the original culture to the saved culture.
Identity
The following elements fall under identity.
Element | Notes |
---|---|
version |
Uses LDML 1.1, so this is |
generation |
Indicates date file was generated. For example, |
special |
A container; all content is drawn from the msLocale schema, see discussion immediately following. |
The following elements fall under identity/special. Except as noted, all values are specified by a type attribute. For example:
<identity>
…
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<!-- A typical case… -->
<msLocale:cultureAndRegionInfoName type="en-US-fabricam"/>
...
<!-- …but here are some examples that use CDATA -->
<msLocale:geoId>244</msLocale:geoId>
<msLocale:languageIsoName type="twoLetters">
en
</msLocale:languageIsoName>
...
</special>
</identity>
In the following table, properties and methods are from CultureAndRegionInfoBuilder unless otherwise noted.
Element | Property / Method | Notes |
---|---|---|
msLocale:cultureAndRegionInfoName |
Examples: "en", "en-US", "en-US-fabricam". |
|
msLocale:cultureAndRegionModifier |
Used only for neutral cultures. type is always "neutral". |
|
msLocale:cultureInfoVersion |
N/A |
Currently, "1.0". |
msLocale:geoId |
Example: "244". This value is specified as text CDATA, rather than with a type attribute. |
|
msLocale:parentName |
Example: "en". |
|
msLocale:specificCulture |
System.Globalization.CultureInfo.CreateSpecificCulture(System.String) |
Example: "en-US". Relevant only for neutral cultures, where it indicates the default specific culture. |
msLocale:languageNameAbbr |
Example: "ENU". |
|
msLocale:languageIsoName type="threeLetters" |
Example: "eng". This value is specified as text CDATA, rather than with a type attribute; type is "threeLetters". |
|
msLocale:languageIsoName type="twoLetters" |
Example: "en". This value is specified as text CDATA, rather than with a type attribute; type is "twoLetters". |
|
msLocale:nativeDisplayName |
Examples: "English (United States)", "Deutsch (Deutschland)" |
|
msLocale:englishName |
Examples: "English (United States)", German (Germany) |
|
msLocale:countryCode |
N/A |
Windows only. The value is specified as CDATA. With the sole exception of Canada (which has the code |
msLocale:regionNativeName |
Examples: " United States", " Deutschland". |
|
msLocale:regionEnglishName |
Examples: "United States", "Germany". |
|
msLocale:regionIsoName type="threeLetters" |
Example: "US". This value is specified as text CDATA, rather than with a type attribute; type is "threeLetters". |
|
msLocale:regionIsoName type="twoLetters" |
Example: "USA". This value is specified as text CDATA, rather than with a type attribute; type is "twoLetters". |
|
msLocale:textInfoName |
Example: "en-US". |
|
msLocale:sortName |
Example: "en-US", "de-DE_phoneb". |
|
msLocale:ietfLanguageTag |
Example: "en-US". |
|
msLocale:englishLanguage |
(Windows only) |
Example: "English", "German". |
Layout
The following element falls under layout.
Element | Notes |
---|---|
special |
A container; all content is drawn from the msLocale schema, see discussion immediately following. |
The following element falls under layout/special.
In the following table, all properties and methods are from CultureAndRegionInfoBuilder.
Element | Property / Method | Notes |
---|---|---|
msLocale:direction |
Text layout direction. This must take one of the following values:
Example: <msLocale:Direction type="left-to-right" /> |
Characters
The following element falls under characters.
Element | Notes |
---|---|
special |
A container; all content is drawn from the msLocale schema, see discussion immediately following. |
The following elements fall under characters/special. Except as noted, Except as noted, all values are specified by a type attribute. Properties and methods are from CultureAndRegionInfoBuilder unless otherwise noted.
Element | Property / Method | Notes |
---|---|---|
msLocale:keyboardLayout |
Value is handled as CDATA. |
|
msLocale:consoleFallbackName |
Example: "en-US". |
|
msLocale:fontSignature |
N/A |
A container for further content drawn from the msLocale schema, see discussion following. |
mslocale:scripts |
N/A |
A container for further content drawn from the msLocale schema, see discussion following. |
The following elements fall under characters/special/msLocale:fontSignature.
msLocale:unicodeRanges
msLocale:defaultCodePages
msLocale:codePages
Each of these is strictly a container for further content drawn from the msLocale schema, see discussion following.
The following elements fall under characters/special/msLocale:fontSignature/msLocale:unicodeRanges. All values are specified by type attributes. This is Windows-only information, and corresponds, in part, to the Windows LOCALESIGNATURE structure.
Element | Property / Method | Notes |
---|---|---|
msLocale:range |
N/A |
Windows only. A value between 0 and 122, representing a bit number in the Unicode subset bitfield (USB), contained in the Windows FONTSIGNATURE structure. This element may recur multiple times. |
msLocale:layoutProgress |
N/A |
Windows only. Always one of the following values:
|
The following elements fall under characters/special/msLocale:fontSignature/msLocale:defaultCodePages and characters/special/msLocale:fontSignature/msLocale:codePages.
msLocale:ansiCodePage
msLocale:ansiOemCodePage
msLocale:oemCodePage
Each of these is strictly a container for msLocale:codePage elements, whose value is specified by a type attribute:
Element | Notes |
---|---|
msLocale:codePage |
Specifies a code page. Must be appropriate to the element in which it is contained. For example, code page "1252" is a Windows "ANSI" code page and would fall under msLocale:ansiCodePage. Code page "932" is an ANSI/OEM code page, and would fall under msLocale:ansiOemCodePage. Code page "855" is an OEM code page, and would fall under msLocale:oemCodePage. |
Under characters/special/msLocale:fontSignature/msLocale:defaultCodePages should be one of the following:
A single msLocale:ansiOemCodePage element containing a single msLocale:codePage element.
A single msLocale:ansiCodePage element containing a single msLocale:codePage element, and a single msLocale:oemCodePage element containing a single msLocale:codePage element.
This msLocale:defaultCodePages data is Windows-only data.
The characters/special/msLocale:fontSignature/msLocale:codePages data is Windows-only information. It lists all of the code pages that can support the language and script in question. Therefore, it is possible for this list to have multiple code pages of the same type. For example:
<msLocale:codePages>
<msLocale:ansiCodePage>
...
</msLocale:ansiCodePage>
<msLocale:oemCodePage>
<msLocale:codePage type="864" />
<msLocale:codePage type="708" />
</msLocale:oemCodePage>
</msLocale:codePages>
The following elements fall under characters/special/msLocale:fontSignature/msLocale:scripts. All values are specified by type attributes. This is Windows-only information; there is no way to set this data in Windows, but it corresponds to the return of the Windows GetStringScripts function.
Element | Property / Method | Notes |
---|---|---|
msLocale:script |
N/A |
Windows only. A four-letter code for a script, such as "Latn" (Latin) or "Cyrl" (Cyrillic). This element may occur any number of times. The codes follow ISO 15924. |
Measurement
The following elements fall under measurement. Properties and methods are from CultureAndRegionInfoBuilder unless otherwise noted.
Element | Property / Method | Notes |
---|---|---|
measurementSystem |
type attribute is either "metric" or "US". |
|
paperSize |
Windows only. |
This is a container for a height and a width element. Valid values are:
|
Dates
Note |
---|
When .NET Framework interprets a date and time formats from a standard LDML element (that is, one drawn from the LDML namespace, as against the msLocale schema), date and time formats are interpreted according to the POSIX rules: for example, the AM/PM indicator is "a". Elements in the msLocale schema follow Microsoft rules for date and time formats for example, the AM/PM indicator is "tt". |
The following element falls under dates.
Element | Notes |
---|---|
calendars |
A container element, see discussion immediately following. |
The following elements fall under dates/calendars. All values are specified by type attributes. Properties and methods are from CultureAndRegionInfoBuilder unless otherwise noted.
Element | Property / Method | Notes |
---|---|---|
default |
type attribute is either "metric" or "US". Identifies a default calendar. This may be any of the following:
In Microsoft-generated files, this will always match AvailableCalendars[0]. |
|
calendar |
AvailableCalendars |
This element may be repeated, once for each available calendar. The possible type values are the same as for default. This element also functions as a container for elements which provide data about the calendar. For non-default calendars, this is normally an empty element. Thus, if "Gregorian" and "Gregorian-US" are both available, and "Gregorian" is the default, the element for "Gregorian-US" will simply be |
The following elements fall under dates/calendars/calendar. All values are specified by type attributes. Properties and methods are from DateTimeFormatInfo unless otherwise noted.
Element | Property / Method | Notes |
---|---|---|
months |
N/A |
A container element, see discussion immediately following. |
days |
N/A |
A container element, see discussion immediately following. |
week |
N/A |
A container element, see discussion immediately following. |
am |
CDATA specifies the text used to label a time before noon. For example, "AM". |
|
pm |
CDATA specifies the text used to label a time after noon. For example, "PM". |
|
dateformat |
N/A |
A container element, see discussion immediately following. |
timeformat |
N/A |
A container element, see discussion immediately following. |
Under dates/calendars/calendar/months is a single monthContext element; it must have a type attributes of "format". Under dates/calendars/calendar/months/monthContext should be four monthWidth elements; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
monthWidth type="wide" |
This element functions as a container. |
|
monthWidth type="abbreviated" |
This element functions as a container. |
|
monthWidth type="genitive" |
This element functions as a container. |
|
monthWidth type="genitiveAbbreviated" |
This element functions as a container. |
Under dates/calendars/calendar/months/monthContext/monthWidth will be one month element for each month of the year (12 or 13 of these, depending on the calendar). For each month element, the type is the number of the month, and the CDATA is the relevant string. For example:
...
<calendar type="Gregorian">
<months>
<monthContext type="format">
<monthWidth type="wide">
<month type="1">January</month>
<month type="2">February</month>
<month type="3">March</month>
...
</monthWidth>
<monthWidth type="abbreviated">
<month type="1">Jan</month>
<month type="2">Feb</month>
<month type="3">Mar</month>
...
</monthWidth>
...
</monthContext>
</months>
</calendar>
Under dates/calendars/calendar/days is a single dayContext element; it must have a type attributes of "format". Under dates/calendars/calendar/days/dayContext should be three dayWidth elements; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
dayWidth type="wide" |
This element functions as a container. |
|
dayWidth type="abbreviated" |
This element functions as a container. |
|
dayWidth type="shorter" |
This element functions as a container. |
Under dates/calendars/calendar/days/dayContext/dayWidth will be one day element for each day of the week. For each day element, the type is one of the values "sun", "mon", "tue", "wed", "thu", "fri", "sat". The CDATA is the relevant string. For example:
...
<calendar type="Gregorian">
<days>
<dayContext type="format">
<dayWidth type="wide">
<day type="sun">Sunday</month>
<day type="mon">Monday</month>
<day type="tue">Tuesday</month>
...
</dayWidth>
...
</dayContext>
</days>
</calendar>
The following elements fall under dates/calendars/calendar/week; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
firstDay |
Attribute day must be one of the following: "sun", "mon", "tue", "wed", "thu", "fri", "sat". |
|
special |
N/A |
A container; all content is drawn from the msLocale schema, see discussion immediately following. |
The following elements fall under dates/calendars/calendar/week/special; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
msLocale:weekRule |
Attribute type must be one of the following:
|
The following element falls under dates/calendars/calendar/dateformats:
Element | Notes |
---|---|
special |
A container; all content is drawn from the msLocale schema, see discussion following. |
The following elements fall under dates/calendars/calendar/dateformats/special; all values are specified by a type attribute; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
msLocale:dateFormatLength type="long" |
A container element, see discussion immediately following. |
|
msLocale:dateFormatLength type="short" |
GetAllDateTimePatterns('d') |
A container element, see discussion immediately following. |
msLocale:yearMonth |
GetAllDateTimePatterns('Y') |
For each relevant DateTime pattern, a container for content. The type attribute specifies a zero-based index; each index should be unique, and there should be no gaps. |
msLocale:monthDay |
Strictly a container. |
The following elements fall under dates/calendars/calendar/dateformats/special/msLocale:dateFormatLength; all values are specified by a type attribute; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
msLocale:default |
N/A |
Corresponds to the type attribute of the default format. In Microsoft-generated LDML files, the default is always "0". |
msLocale:dateFormat |
GetAllDateTimePatterns ('D'), GetAllDateTimePatterns ('d') |
For each relevant DateTime pattern, a container for content. The type attribute specifies a zero-based index; each index should be unique, and there should be no gaps. |
dates/calendars/calendar/dateformats/special/msLocale:dateFormatLength /msLocale:dateformat, dates/calendars/calendar/dateformats/special/msLocale:yearMonth, and dates/calendars/calendar/dateformats/special/msLocale:monthDay are containers for msLocale:pattern elements that give their values as CDATA. For example:
<dateFormats>
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<msLocale:dateFormatLength type="long">
<msLocale:default type="0"/>
<msLocale:dateFormat type="0">
<msLocale:pattern>dddd, MMMM dd, yyyy</pattern>
</msLocale:dateFormat>
<msLocale:dateFormat type="1">
<msLocale:pattern>MMMM dd, yyyy</pattern>
</msLocale:dateFormat>
...
</msLocale:dateFormatLength>
...
<msLocale:yearMonth type=”0”>
<msLocale:pattern>MMMM, yyyy</msLocale:pattern>
</msLocale:yearMonth>
<msLocale:yearMonth type=”1”>
<msLocale:pattern>mm, yy</msLocale:pattern>
</msLocale:yearMonth>
<msLocale:monthDay>
<msLocale:pattern>MMMM dd</msLocale:pattern>
</msLocale:monthDay>
</special>
</dateFormats>
The following element falls under dates/calendars/calendar/timeformats:
Element | Notes |
---|---|
Special |
A container; all content is drawn from the msLocale schema, see discussion following. |
The following elements fall under dates/calendars/calendar/timeformats/special; all values are specified by a type attribute; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
msLocale:durationFormats |
N/A |
A container element, see discussion immediately following. Windows-only data. |
msLocale:timeFormatLength type="long" |
GetAllDateTimePatterns('T') |
A container element, see discussion following. |
msLocale:timeFormatLength type="short" |
GetAllDateTimePatterns('t') |
A container element, see discussion following. |
The following elements fall under dates/calendars/calendar/dateformats/special/msLocale:durationFormats; ** all values are specified by a type attribute:
Element | Property / Method | Notes |
---|---|---|
msLocale:default |
N/A |
Corresponds to the type attribute of the default format. In Microsoft-generated files, the default is always "0". Windows-only data. |
msLocale:durationFormat |
N/A |
For each relevant DateTime pattern, a container for content. The type attribute specifies a zero-based index; each index should be unique, and there should be no gaps. Windows-only data. |
The following elements fall under dates/calendars/calendar/dateformats/special/msLocale:timeFormatLength; ** all values are specified by a type attribute; properties and methods are from DateTimeFormatInfo:
Element | Property / Method | Notes |
---|---|---|
msLocale:default |
N/A |
Corresponds to the type attribute of the default format. In Microsoft-generated files, the default is always "0". |
msLocale:timeFormat |
GetAllDateTimePatterns ('T'), GetAllDateTimePatterns ('t') |
For each relevant DateTime pattern, a container for content. The type attribute specifies a zero-based index; each index should be unique, and there should be no gaps. |
dates/calendars/calendar/dateformats/special/msLocale:durationFormats/msLocale:durationFormat and dates/calendars/calendar/dateformats/special/msLocale:timeFormatLength/msLocale:timeformat are containers for msLocale:pattern elements that give their values as CDATA. For example:
<timeFormats>
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<msLocale:durationFormats>
<msLocale:default type="0" />
<msLocale:durationFormat type="0">
<msLocale:pattern>HH:mm:ss</msLocale:pattern>
</msLocale:durationFormat>
</msLocale:durationFormats>
<msLocale:timeFormatLength type="long">
<msLocale:default type="0"/>
<msLocale:timeFormat type="0">
<msLocale:pattern>h:mm:ss tt</msLocale:pattern>
</msLocale:timeFormat>
<msLocale:timeFormat type="1">
<msLocale:pattern>h:mm:ss a</msLocale:pattern>
</timeFormat>
...
</timeFormatLength>
...
</special>
</timeFormats>
Numbers
The following elements fall under numbers.
Element | Notes |
---|---|
Symbols |
A container element, see discussion following. |
Currencies |
A container element, see discussion following. |
special |
A container; all content is drawn from the msLocale schema, see discussion following. |
The following elements fall under numbers/symbols. Except as noted, these give their data as CDATA; properties and methods are from NumberFormatInfo unless otherwise noted:
Element | Property / Method | Notes |
---|---|---|
Decimal |
Example: "." |
|
group |
Example: "," |
|
list |
Example: ";" |
|
percentSign |
Example: "%" |
|
infinity type="positive" |
Example: "Infinity" |
|
infinity type="negative" |
Example: "-Infinity" |
|
nan |
"Not a number" symbol. Example: "NaN". |
|
special |
N/A |
A container; all content is drawn from the msLocale schema, see discussion following. |
The following elements fall under numbers/symbols/special. Except as noted, these give their data as CDATA; properties and methods are from NumberFormatInfo unless otherwise noted:
Element | Property / Method | Notes |
---|---|---|
msLocale:currencyDecimalSeparator |
Example: "." |
|
msLocale:currencyGroupSeparator |
Example: "," |
|
msLocale:leadingZero |
N/A |
Windows only. No CDATA; type attribute must be either "yes" or "no" to allow or disallow leading zeroes. |
For example:
<symbols>
<decimal>.</decimal>
<group>,</group>
…
<infinity type="positive">Infinity</infinity>
<infinity type="negative">-Infinity</infinity>
…
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<msLocale:currencyDecimalSeparator>
.
</msLocale:currencyDecimalSeparator>
<msLocale:currencyGroupSeparator>
,
</msLocale:currencyGroupSeparator>
<msLocale:leadingZero type="yes" />
</special>
</symbols>
The following element falls under numbers/currencies.
Element | Notes |
---|---|
currency |
A container element, see discussion following. type must be specified as "default". |
The following elements fall under numbers/currencies/currency. Except as noted, these give their data as CDATA; properties and methods are from CultureAndRegionInfoBuilder:
Element | Property / Method | Notes |
---|---|---|
symbol |
Example: "$" |
|
displayName |
Example: "Dollar" |
|
Special |
N/A |
A container; all content is drawn from the msLocale schema, see discussion following. |
The following elements fall under numbers/currencies/currency/special. Except as noted, these give their data as CDATA; properties and methods are from CultureAndRegionInfoBuilder unless otherwise noted:
Element | Property / Method | Notes |
---|---|---|
msLocale:isoCurrency |
ISOCurrencySymbol |
Example: "USD" |
msLocale:currencyEnglishName |
Example: "Dollar" |
For example:
<currencies>
<currency type="default">
<symbol>$</symbol>
<displayName>Dollar</displayName>
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<msLocale:isoCurrency>USD</msLocale:isoCurrency>
<msLocale:currencyEnglishName>
Dollar
</msLocale:currencyEnglishName>
</special>
</currency>
The following elements fall under numbers/currencies/special. All values are specified by type attributes unless otherwise noted; properties and methods are from NumberFormatInfo unless otherwise noted:
Element | Property / Method | Notes |
---|---|---|
msLocale:decimalDigits |
The value is specified as CDATA. Example: "2". |
|
msLocale:negativePattern |
Values that may be used here are listed at NumberNegativePattern. |
|
msLocale:currencyDecimalDigits |
Example: "2". Note that in contrast to msLocale:decimalDigits, this is specified in the type attribute. |
|
msLocale:currencyPositivePattern |
Values that may be used here are listed at CurrencyPositivePattern. |
|
msLocale:currencyNagativePattern |
Values that may be used here are listed at CurrencyNegativePattern. |
|
msLocale:percentPositivePattern |
Values that may be used here are listed at PercentPositivePattern. |
|
msLocale:percentNagativePattern |
Values that may be used here are listed at PercentNegativePattern. |
|
msLocale:groupSizes |
The actual grouping size is specified as CDATA. The type attribute serves to serialize this. There can be any number of these, each with a unique type attribute, serialized starting from "0". This starts from the least significant group of digits, as explained at NumberGroupSizes. |
|
msLocale:nativeDigits |
One for each digit. The type attribute is a digit "0" through "9"; the CDATA specifies the character used to represent this digit. |
|
msLocale:digitSubstitution |
Valid values for the type attribute are:
|
For example:
<numbers>
...
<special xmlns:msLocale="https://schemas.microsoft.com/globalization/2005/carib/ldml">
<msLocale:decimalDigits>2</msLocale:decimalDigits>
<msLocale:negativePattern type="1"/>
<msLocale:currencyDecimalDigits type="2"/>
<msLocale:currencyPositivePattern type="0"/>
<msLocale:currencyNegativePattern type="0"/>
<msLocale:percentNegativePattern type="0"/>
<msLocale:percentPositivePattern type="0"/>
<msLocale:groupSizes type="0">3</msLocale:groupSizes>
<msLocale:currencyGroupSizes type="0">
3
</msLocale:currencyGroupSizes>
<msLocale:nativeDigits type="0">0</msLocale:nativeDigits>
<msLocale:nativeDigits type="1">1</msLocale:nativeDigits>
...
<msLocale:nativeDigits type="9">9</msLocale:nativeDigits>
<msLocale:digitSubstitution type="context"/>
</special>
</numbers>