Locale Data Markup Language

Summary: This document describes an XML format (vocabulary) for the exchange of structured locale data. For more information, see the openI18n page.
Version: 1.0 (draft)
Date: 2003-06-09
Author: Mark Davis
Latest Version: http://oss.software.ibm.com/cvs/icu/~checkout~/locale/locale_data_markup.html
Older Versions: http://oss.software.ibm.com/cvs/icu/locale/locale_data_markup.html
Feedback: http://www.openi18n.org/locale-bugs/public
Namespace: http://www.openi18n.org/subgroups/lade/locale/ldml
DTDs: draft:
http://oss.software.ibm.com/cvs/icu/~checkout~/locale/LocaleElements.dtd
at 1.0 release (not yet available):
http://oss.software.ibm.com/cvs/icu/~checkout~/locale/LocaleElements1.0.dtd
http://oss.software.ibm.com/cvs/icu/~checkout~/locale/LocaleElementsSupplemental1.0.dtd
License: See Copyright and Permission Notice

Contents

Introduction

Not long ago, computer systems were like separate worlds, isolated from one another. The internet and related events have changed all that. A single system can be built of many different components, hardware and software, all needing to work together. Many different technologies have been important in bridging the gaps; in the internationalization arena, Unicode has provided a lingua franca for communicating textual data. But there remain differences in the locale data used by different systems.

Common, recommended practice for internationalization is to store and communicate language-neutral data, and format that data for the client. This formatting can take place on any of a number of the components in a system; a server might format data based on the user's locale, or it could be that a client machine does the formatting. The same goes for parsing data, and locale-sensitive analysis of data.

But there remain significant differences across systems and applications in the locale-sensitive data used for such formatting, parsing, and analysis. Many of those differences are simply gratuitous; all within acceptable limits for human beings, but resulting in different results. In many other cases there are outright errors. Whatever the cause, the differences can cause discrepancies to creep into a heterogeneous system. This is especially serious in the case of collation (sort-order), where different collation caused not only ordering differences, but also different results of queries! That is, with a query of customers with names between "Arnold, James" and "Abbot, Cosmo", if different systems have different sort orders, different lists will be returned. (For comparisons across systems formatted as HTML tables, see Comparisons.)

There are a number of steps that can be taken to improve the situation. The first is to provide an XML format for locale data interchange. This provides a common format for systems to interchange data so that they can get the same results. The second is to gather up locale data from different systems, and compare that data to find any differences. The third is to provide an online repository for such data. The fourth is to have an open process for reconciling differences between the locale data used on different systems and validating the data, to come up with a useful, common, consistent base of locale data.

Note: There are many different equally valid ways in which data can be judged to be "correct" for a particular locale. The goal for the common locale data is to make it as consistent as possible with existing locale data, and acceptable to users in that locale.

This document describes one of those pieces, an XML format for the communication of locale data. With it, for example, collation rules can be exchanged, allowing two implementations to exchange a specification of collation. Using the same specification, the two implementations will achieve the same results in comparing strings.

Additional Data Sources

To properly localize, parse, and format data requires ancillary information, which is not expressed in LDML. The sources for this data include:

In addition, various standards define codes that are used as keys or values in LDML. These include:

Other sources that may be useful for comparison include:

What is a locale?

Before diving into the XML structure, it is helpful to describe the model behind the structure. People do not have to subscribe to this model to use the data, but they do need to understand it so that the data can be correctly translated into whatever model their implementation uses.

The first issue is basic: what is a locale? In this document, a locale is an id that refers to a set of user preferences that tend to be shared across significant swathes of the world. Traditionally, the data associated with this id provides support for formatting and parsing of dates, times, numbers, and currencies; for measurement units, for sort-order (collation), plus translated names for timezones, languages, countries, and scripts. They can also include text boundaries (character, word, line, and sentence), text transformations (including transliterations), and support for other services.

Locale data is not cast in stone: the data used on someone's machine generally may reflect the US format, for example, but preferences can typically set to override particular items, such as setting the data format for 2002.03.15, or using metric vs. Imperial measurement units. In the abstract, locales are simply one of many sets of preferences that, say, a website may want to remember for a particular user. Depending on the application, it may want to also remember the user's timezone, preferred currency, preferred character set, smoker/non-smoker preference, meal preference (vegetarian, kosher, etc.), music preference, religion, party affiliation, favorite charity, etc.

Locale data in a system may also change over time: country boundaries change; governments (and currencies) come and go: committees impose new standards; bugs are found and fixed in the source data; and so on. Thus the data needs to be versioned for stability over time.

In general terms, the locale id is a parameter that is supplied to a particular service (date formatting, sorting, spell-checking, etc.). The format in this document does not attempt to collect together all the data that could conceivably be used by all possible services. Instead, it collects together data that is in common use in systems and internationalization libraries for basic services. The main difference among locales is in terms of language; there may also be some differences according to different countries or regions.

Note: As far as we are concerned — as a completely practical matter — two languages are different if they require substantially different localized resources. Distinctions according to spoken form are important in some contexts, but the written form is by far and away the most important issue for data interchange. Unfortunately, this is not the principle used in ISO 639, which has the unproductive notion (data interchange) that only spoken language matters (it is also not completely consistent about this, however).

RFC 3066 can express a difference if the use of written languages happens to correspond to region boundaries expressed as ISO 639 country codes, and has recently added codes that allow it to express some important cases that are not distinguished by ISO 639 codes. These include simplified and traditional Chinese (both used in Hong Kong S.A.R.); Latin Serbian, Azeri, and Uzbek in both Cyrillic and; Azeri in Arab.

We will speak of data as being "in locale X". That does not imply that a locale is a collection of data; it is simply shorthand for "the set of data associated with the locale id X". Each individual piece of data is called a resource, and a tag indicating the key of resource is called a resource tag.

Locale IDs

A locale id consists of the following format:

locale_id := base_locale_id options?
base_locale_id := language_code ("_" script_code)? ("_" territory_code)? ("_" variant_code)?
options := "@" key "=" type ("," key "=" type )*

As usual x? means that x is optional; x* means that x occurs zero or more times.

The field values are given in the following table. All field values are case-insensitive, except for the key and type, which are case-sensitive. However, customarily the language code is lowercase, the territory and variant codes are uppercase, and the script code is titlecase (that is, first character uppercase and other characters lowercase).

Locale Field Definitions
Field Allowable Characters Allowable values
language_code ASCII letters ISO-639 2-letter codes where they exist; otherwise 3-letter codes (the mapping between 2-letter codes and 3-letter codes is not part of this format.), or RFC 3066 codes that do not contain script or territory codes.
script_code ASCII letters ISO 15924 4-letter codes. In most cases the script is implicit, since the language is only customarily written in a single script.
territory_code ASCII letters ISO-3166 2-letter codes. Also known as a country_code, although the territories may not be countries.
variant_code ASCII letters described below
key ASCII letters and digits
type ASCII letters, digits, and "-"

Examples:

en
fr_BE
de_DE@collation=phonebook,currency=pre-euro

The locale id format generally follows the description in the OpenI18N Locale Naming Guideline, with some enhancments. The main differences from the those guidelines are that the locale id:

  1. does not include a charset (since the data in the locale is always in Unicode),
  2. adds the ability to have a variant, as in Java
  3. adds the ability to discriminate the written language by script (or script variant).

  4. is a superset of RFC 3066 codes.

Note: The language + script + territory code combination can itself be considered simply a language code: For more information, see Appendix D: Language and Locale IDs.

A locale that only has a language code (and possibly a script code) is called a language locale; one with both language and territory codes is called a territory locale (or country locale).

The variant codes specify particular variants of the locale, typically with special options. They cannot overlap with script or territory codes, so they must have either one letter or have more than 4 letters. The currently defined variants include:

Variant Definitions
variant Description
bokmal Bokmål, variant of Norwegian
nynorsk Nynorsk, variant of Norwegian
aaland Åland, variant of Norwegian

Note: The first two of the above variants are for backwards compatibility. Typically the entire contents of these are defined by an <alias> element pointing at nb_NO (Norwegian Bokmål) and nn_NO(Norwegian Nynorsk) locale IDs.

The currently defined optional key/type combinations include:

Key/Type Definitions
key type Description
collation phonebook For a phonebook-style ordering (used in German).
pinyin Pinyin order for CJK characters
traditional For a traditional-style sort (as in Spanish)
stroke Stroke order for CJK characters
direct Hindi variant
posix A "C"-based locale.
calendar gregorian (default)
arabic Astronomical Arabic
chinese Traditional Chinese calendar
civil-arabic Civil (algorithmic) Arabic calendar
hebrew Traditional Hebrew Calendar
japanese Imperial Calendar (same as Gregorian except for the year, with one era for each Emperor)
thai-buddhist Thai Buddhist Calendar (same as Gregorian except for the year)

Note: For information on the process for adding additional variants or element/type pairs, see http://www.openi18n.org/subgroups/lade/locale/.

Locale Inheritance

The XML format relies on an inheritance model, whereby the resources are collected into bundles, and the bundles organized into a tree. Data for the many Spanish locales does not need to be duplicated across all of the countries having Spanish as a national language. Instead, common data is collected in the Spanish language locale, and territory locales only need to supply differences. The parent of all of the language locales is a generic locale known as root. Wherever possible, the resources in the root are language & territory neutral. For example, the collation order in the root is the UCA (see UAX #10). Since English language collation has the same ordering, the 'en' locale data does not need to supply any collation data, nor does either the 'en_US' or the 'en_IE' locale data.

Given a particular locale id "en_US_someVariant", the search chain for a particular resource is the following.

en_US_someVariant
en_US
en
root

If a type and key are supplied in the locale id, then logically the chain from that id to the root is searched for a resource tag with a given type, all the way up to root. If no resource is found with that tag and type, then the chain is searched again without the type.

Thus the data for any given locale will only contain resources that are different from the parent locale. For example, most territory locales will inherit the bulk of their data from the language locale: "en" will contain the bulk of the data: "en_US" will only contain a few items like currency. All data that is inherited from a parent is presumed to be valid, just as valid as if it were physically present in the file. This provides for much smaller resource bundles, and much simpler (and less error-prone) maintenance.

Where this inheritance relationship does not match a target system, such as POSIX, the data logically should be fully resolved in converting to a format for use by that system, by adding all inherited data to each locale data set.

The locale data does not contain general character properties that are derived from the Unicode Character Database data [UCD]. That data being common across locales, it is not duplicated in the bundles. Constructing a POSIX locale from the following data requires use of that data. In addition, POSIX locales may also specify the character encoding, which requires the data to be transformed into that target encoding.

Multiple Inheritance

In clearly specified instances, resources may inherit from within the same locale. For example, currency format symbols inherit from the number format symbols; the Buddhist calendar inherits from the Gregorian calendar. This only happens where documented in this specification. In these special cases, the inheritance within the locale supercedes the inheritance from the parent.

Data Access

Data can be accessed by means of a URL. A locale URL has the following structure:

base "/" platform "/" base_locale_id ".xml" ("?" ("version=" version | transformed_options)

The version is the version of the entire tree, not of a particular resource bundle, or resource within a bundle. The format for the version depends on the source of the data. For example, for openoffice.org the current version (at the time of this writing) would be 1.2, and for icu the current version at the time of this writing would be 2.2. The transformed options are the <options> from the Locale ID with the "@" removed, and "," converted to "&".

Example, where base = http://openi18n.org/locale and platform = icu

http://openi18n.org/locale/icu/de_DE.xml?version=2.2&collation=phonebook

At this point in time, there is not a mechanism for querying the base to determine which platforms, which versions of each platform, and which locales in the version are supported. In the future there will be more information, accessible at http://www.openi18n.org/subgroups/lade/locale/.

XML Format

The following sections describe the structure of the XML format for locale data. To start with, the root element is <localeData>. That element contains the following elements:

The structure of each of these elements and their contents will be described below. The first few elements have little structure, while dates, numbers, and collations are more involved.

In general, all translatable text in this format is in element contents, while attributes are reserved for types and non-translated information (such as numbers or dates). The reason that attributes are not used for translatable text is that spaces are not preserved, and we cannot predict where spaces may be significant in translated material.

Note that the data in examples given below is purely illustrative, and doesn't match any particular language. For a more detailed example of this format, see Example. There is also a DTD for this format, but remember that the DTD alone is not sufficient to understand the semantics, the constraints, nor  the interrelationships between the different elements and attributes. You may wish to have copies of each of these to hand as you proceed through the rest of this document.

Note: To compare with the ICU locale data format and contents, see ICU Data.

Common Elements

At any level in any element, two special elements are allowed.

<special xmlns="xxx">

This element is designed to allow for arbitrary additional annotation and data that is product-specific. It has one required attribute, which specifies the XML namespace of the special data. For example:

<special owner="http://www.opengroup.org/regproducts/xu.htm">
    <!-- old abbreviations for pre-GUI days -->
    <messages>
        <no>No</no>
        <yes>Yes</yes>
        <shortYes>Y</shortYes>
        <shortNo>N</shortNo>
    </messages>
</special>

<alias source="<locale_ID>">

The contents of any element can be replaced by an alias, which points to another source for the data. The resource is to be fetched from the corresponding location in the other source. Normal resource searching is to be used; take the following example:

<localeData>
  <collations>
    <collation type="phonebook">
      <alias source="de_DE" type="phonebook">
    </collation>
  </collation>
</localeData>

The resource bundle at "de_DE" will be searched for a resource element at the same position in the the same tree with type "collation". If not found there, then the resource bundle at "de" will be searched, etc.

<displayName>

Many elements can have a display name. This is a translated name that can be presented to users when discussing the particular service. For example, a number format, used to format numbers using the conventions of that locale, can have translated name for presentation in GUIs.

  <numberFormat>
    <displayName>Prozentformat</displayName>
...
  <numberFormat>

<default type="someID"/>

In some cases, a number of elements are present. The default element can be used to indicate which of them is the default, in the absence of other information. The value of the type attribute is to match the value of the type attribute for the selected item.

<numberFormats>
    <default type="scientific"/>
    <numberFormat type="decimal">...</numberFormat>
    <numberFormat type="percent">...</numberFormat>
    <numberFormat type="scientific">...</numberFormat>
</numberFormats>

Like all other elements, the <default> element is inherited. Thus, it can also refer to inherited resources. For example, suppose that the above resources are present in fr, and that in fr_BE we have the following:

<numberFormats>
  <default type="decimal"/>
</numberFormats>

In that case, the default number format for fr_BE would be the inherited "decimal" resource from fr. Now suppose that we had in fr_CA:

<numberFormats>
  <numberFormat type="scientific">...</numberFormat>
</numberFormats>

In this case, the <default> is inherited from fr, and has the value "scientific". It thus refers to this new "scientific" pattern in this resource bundle.

Common Attributes

<... type="stroke" ...>

The attribute type is also used to indicate an alternate resource that can be selected with a matching type=option in the locale id modifiers, or be referenced by a default element. For example:

<localeData>
  ...
  <currencies>
    <currency>...</currency>
    <currency type="preEuro">...</currency>
  </currencies>
</localeData>

If there is no type attribute present, then the value is assumed to be "standard".

<... draft="true" ...>

If this attribute is present, it indicates the status of all the data in this element and any subelements (unless they have a contrary draft value).

<... standard="..." ...>

The value of this list is a list of strings representing standards: international, national, organization, or vendor standards. The presence of this attribute indicates that the data in this element is compliant with the indicated standards. Where possible, for uniqueness, the string should be a URL that represents that standard. The strings are separated by commas; leading or trailing spaces on each string are not significant. Examples:

<collation standard=”MSA 200:2002”>
<dateFormatStyle standard=”http://www.iso.ch/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=26780&ICS1=1&ICS2=140&ICS3=30”>


<identity>

The identity element contains information identifying the target locale for this data, and general information about the version of this data.

<version number="1.1">

The version element provides, in an attribute, the version of this file.  The contents of the element can contain textual notes about the changes between this version and the last. For example:

<version number="1.1">Various notes and changes in version 1.1</version>

<generation date="2002-08-28" />

The generation element contains the last modified date for the data. The data is in XML Schema format (yyyy-mm-dd).

<language type="en"/>

The language code is the primary part of the specification of the locale id, with values as described above.

<script type="Latn" />

The script field may be used in the identification of written languages, with values described above.

<territory type="US"/>

The territory code is a common part of the specification of the locale id, with values as described above.

<variant type="nynorsk"/>

The variant code is the tertiary part of the specification of the locale id, with values as described above.

<localeDisplayNames>

Display names for scripts, languages, countries, and variants in this locale are supplied by this element. These supply localized names for these items for use in user-interfaces for displaying lists of locales and scripts. Examples are given below:

<scripts>

This element can contain an number of script elements. Each script element provides the localized name for a script, given by the value of the type attribute. The script IDs can be either the long or short forms from Scripts.txt in the UCD. (See UTR #24: Script Names for more information.) For example, in the language of this locale, the name for the Latin script might be "Romana", and for the Cyrillic script is "Kyrillica". That would be expressed with the following.

<script type="Latin">Romana</script>
<script type="Cyrillic">Kyrillica</script>

<languages>

This contains a list of elements that provide the user-translated names for language codes from ISO-639, as described in Locale_IDs.

<language type="ab">Abkhazian</language>
<language type="aa">Afar</language>
<language type="af">Afrikaans</language>
<language type="sq">Albanian</language>

<territories>

This contains a list of elements that provide the user-translated names for territory codes from ISO-3166, as described in Locale_IDs.

<territory type="AF">Afghanistan</territory>
<territory type="AL">Albania</territory>
<territory type="DZ">Algeria</territory>
<territory type="AD">Andorra</territory>
<territory type="AO">Angola</territory>
<territory type="US">United States</territory>

<variants>

This contains a list of elements that provide the user-translated names for the variant_code values described in Locale_IDs.

<variant type="nynorsk">Nynorsk</variant>

<keys>

This contains a list of elements that provide the user-translated names for the key values described in Locale_IDs.

<key type="collation">Sortierung</key>

<types>

This contains a list of elements that provide the user-translated names  for the type values described in Locale_IDs. Since the translation of an option name may depend on the key it is used with, the latter is optionally supplied.

<type type="phonebook" key="collation">Telefonbuch</type>

<layout>

This top-level element specifies general layout features. It currently only has one possible element (other than <special>, which is always permitted).

<orientation lines="top-to-bottom" characters="left-to-right" />

The lines and characters attributes specify the default general ordering of lines, and characters within a line. The values are:

Orientation Attributes
Vertical top-to-bottom
bottom-to-top
Horizontal left-to-right
right-to-left

If the lines value is vertical then the characters value must be horizontal, and vice versa. This does not override the ordering behavior of bidirectional text; it does, however, supply the paragraph direction for that text (for more information, see UAX #9).

<encodings>

The encodings element does not (unlike POSIX) specify the encoding of the data itself. Instead, it provide optional information that can be helpful in picking among character encodings that are typically used to transmit data in the language of this locale. It typically only occurs in a language locale, not in a language/territory locale.

<exemplarCharacters>[a-zåæø]</exemplarCharacters>

This element indicates that normal usage of the language of this locale requires these letters. An encoding that cannot encompass at least these letters is inappropriate for encoding data in the language of this locale. The list of characters is in UnicodeSet format, which allows boolean combinations of sets of letters, including those specified by Unicode properties.

The letters do not necessarily form a complete set (especially for languages using large character sets, such as CJK). Nor does the list necessarily include letters that are used in common foreign words used in that language. The letters are only the lowercase alternatives, but implicitly include the normal "case-closure": all uppercase and titlecase variants. For the special case of Turkish, the dotted capital I should be included. Sequences of characters that are considered to be a single letter in the alphabet, such as "ch" can be included, using curly braces (e.g., [[a-z{ch}{ll}{rr}] - [w]])

<mapping registry="iana" type="windows-1252"/>

There can be multiple mapping elements. Each indicates the character conversion mapping table name for a character encoding that is commonly used to encode data in the language of this locale. The version field of the mapping table is omitted. The ordering among the mapping elements is not significant. The mapping elements themselves are not inherited from parents.

The registry indicates the source of the encoding. Currently the only registry that can be used is "iana", which specifies use of  an IANA name.  Note: while IANA names are not precise for conversion (see UTR #22: Character Mapping Tables), they are sufficient for this purpose.

<delimiters>

The delimiters supply common delimiters for bracketing quotations. The quotation marks are used with simple quoted text, such as:

He said, “Don’t be absurd!”

The alternate marks are used with embedded quotations, such as:

He said, “Remember what the Mad Hatter said: ‘Not the same thing a bit! Why you might just as well say that “I see what I eat” is the same thing as “I eat what I see”!’”

<quotationStart></quotationStart>
<quotationEnd></quotationEnd>
<alternateQuotationStart></alternateQuotationStart>
<alternateQuotationEnd></alternateQuotationEnd>

<measurement>

<measurementSystem type="US"/>

The measurement system is the normal measurement system in common everyday use (except for date/time). The values are "metric" (= ISO 1000) or "US"; others will be added over time.

Note: In the future, we may need to add display names for the particular measurement units (millimeter vs millimetre vs whatever the Greek, Russian, etc are), and a message format for position those with respect to numbers. E.g. "{number} {unitName}" in some languages, but "{unitName} {number}" in others.

Note: Numbers indicating measurements should never be interchanged without known dimensions. You never want the number 3.51 interpreted as 3.51 feet by one user and 3.51 meters by another. However, this element can be used to convert dimensioned numbers into the user's desired notation: so the value of 3.51 meters can be formatted as 11.52 feet on a particular user's system.

The paperSize element gives the normal business letter size, and customary units. The units for the numbers are always in millimeters.

<paperSize>
  <height>279</height>
  <width>216</width>
</paperSize>

<date>

This top-level element contains information regarding the format and parsing of dates and times. The data is based on the Java/ICU format. Most of these are fairly self-explanatory, except minDays and localizedPatternChars. For information on this, and more information on other elements and attributes, see the Java API: DateFormat, DateFormatSymbols, SimpleDateFormat.

Note: there is an on-line demonstration of date formatting and parsing at Locale Explorer (pick the locale and scroll to "Date Patterns").

The <dates> element has three possible sub-elements: <localizedPatternCharacters>, <calendars> and <timeZoneNames>

<localizedPatternChars>GyMdkHmsSEDFwWahKz</localizedPatternChars>

The interpretation of this is explained in DateFormatSymbols.

<calendars>

This element contains multiple <calendar> elements, each of which specifies the fields used for formatting and parsing dates and times according to the given calendar. The month names are identified numerically, starting at 1. The day names are identified with short strings, since there is no universally-accepted numeric designation.

Many calendars will only differ from the Gregorian Calendar in the year and era values. For example, the Japanese calendar will have many more eras (one for each Emperor), and the years will be numbered within that era. All other calendars inherit from the Gregorian calendar (which must be present), so only the differing data will be present.

Example:

  <calendar type="gregorian">
    <monthNames>
        <month type="1">January</month>
        <month type="2">February</month>
...
        <month type="11">November</month>
        <month type="12">December</month>
    </monthNames>
    <monthAbbr>
        <month type="1">Jan</month>
        <month type="2">Feb</month>
...
        <month type="11">Nov</month>
        <month type="12">Dec</month>
    </monthAbbr>

    <dayNames>
        <day type="sun">Sunday</day>
        <day type="mon">Monday</day>
...
        <day type="fri">Friday</day>
        <day type="sat">Saturday</day>
    </dayNames>
    <dayAbbr>
        <day type="sun">Sun</day>
        <day type="mon">Mon</day>
...
        <day type="fri">Fri</day>
        <day type="sat">Sat</day>
    </dayAbbr>

    <week>
        <minDays count="1"/>
        <firstDay day="sun"/>
        <weekendStart day="fri" time="18:00"/>
        <weekendEnd day="sun" time="18:00"/>
    </week>

    <am>AM</am>
    <pm>PM</pm>

    <eras>
       <eraAbbr>
        <era type="0">BC</era>
        <era type="1">AD</era>
       </eraAbbr>
       <eraName>
        <era type="0">Before Christ</era>
        <era type="1">Anno Domini</era>
       </eraName>
    </eras>
    <dateFormats>
      <default type=”medium”/>
      <dateFormatLength type=”full”>
        <dateFormat>
          <pattern>EEEE, MMMM d, yyyy</pattern>
        </dateFormat>
       </dateFormatLength>
     <dateFormatLength type="medium">
       <default type="DateFormatsKey2">
       <dateFormat type="DateFormatsKey2">
        <pattern>MMM d, yyyy</pattern>
       </dateFormat>
       <dateFormat type="DateFormatsKey3">
         <pattern>MMM dd, yyyy</pattern>
        </dateFormat>
      </dateFormatLength>
    <dateFormats>
     <timeFormats>
       <default type="medium"/>
       <timeFormatLength type=”full”>
         <timeFormat>
           <displayName>DIN 5008 (EN 28601)</displayName>
           <pattern>h:mm:ss a z</pattern>
         </timeFormat>
       </timeFormatLength>
       <timeFormatLength type="medium">
         <timeFormat>
           <pattern>h:mm:ss a</pattern>
         </timeFormat>
       </timeFormatLength>
     </timeFormats>

     <dateTimeFormats>
       <default type="medium"/>
       <dateTimeFormatLength type=”full”>
         <dateTimeFormat>
            <pattern>{0} {1}</pattern>
         </dateTimeFormat>
       </dateTimeFormatLength>
     </dateTimeFormats>
  </calendar>

  <calendar class="thai-buddhist">
    <eras>
        <era type="0">BE</era>
    </eras>
  </calendar>

<timeZoneNames>

The timezone IDs are language-independent, and follow the Olson data. However, the display names for those IDs can vary by locale. The generic time is so-called wall-time; what clocks use when they are correctly switched from standard to daylight time at the mandated time of the year.

<zone type="America/Los_Angeles" >
    <long>
        <generic>Pacific Time</generic>
        <standard>Pacific Standard Time</standard>
        <daylight>Pacific Daylight Time</daylight>
    </long>
    <short>
        <generic>PT</generic>
        <standard>PST</standard>
        <daylight>PDT</daylight>
    </short>
    <exemplarCity>Los Angeles</exemplarCity>
</zone>

<zone type="Europe/London">
     <long>
        <generic>British Time</generic>
        <standard>British Standard Time</standard>
        <daylight>British Daylight Time</daylight>
    </long>
    <exemplarCity>York</exemplarCity>
</zone>

Note: Transmitting "14:30" with no other context is incomplete unless it contains information about the time zone. Ideally one would transmit neutral-format date/time information, commonly in UTC, and localize as close to the user as possible. (For more about UTC, see NIST Time and Frequency Division Home PageU.S. Naval Observatory: What is Universal Time?.)

The conversion from local time into UTC depends on the particular time zone rules, which will vary by location. The standard data used for converting local time (sometimes called wall time) to UTC and back is the Olson data, used by UNIX, Java, ICU, and others. The data includes rules for matching the laws for time changes in different countries. For example, for the US it is:

"During the period commencing at 2 o'clock antemeridian on the first Sunday of April of each year and ending at 2 o'clock antemeridian on the last Sunday of October of each year, the standard time of each zone established by sections 261 to 264 of this title, as modified by section 265 of this title, shall be advanced one hour..." (United States Law - 15 U.S.C. §6(IX)(260-7)).

Each region that has a different timezone or daylight savings time rules, either now or at any time in the past, is given a unique internal ID, such as Europe/Paris. As with currency codes, these are internal codes that should be localized if exposed to a user (such as in the Windows Control Panels>Date/Time>Time Zone).

Unfortunately, laws change over time, and will continue to change in the future, both for the boundaries of timezone regions and the rules for daylight savings. Thus the Olson data is continually being augmented. Any two implementations using the same version of the Olson data will get the same results for the same IDs (assuming a correct implementation). However, if implementations use different versions of the data they may get different results. So if precise results are required then both the Olson ID and the Olson data version must be transmitted between the different implementations.

<numbers>

The numbers element supplies information for formatting and parsing numbers and currencies. It has three sub-elements: <symbols>, <numbers>, and <currencies>. The data is based on the Java/ICU format. The currency IDs are from ISO 4217. For more information, including the pattern structure, see the Java API: NumberFormat, DecimalFormat, DecimalFormatSymbols.

Note: there is an on-line demonstration of number formatting and parsing at Locale Explorer (pick the locale and scroll to "Number Patterns").

<symbols>
      <decimal>.</decimal>
      <group>,</group>
      <list>;</list>
      <percentSign>%</percentSign>
      <nativeZeroDigit>0</nativeZeroDigit>
      <patternDigit>#</patternDigit>
      <plusSign>+</plusSign>
      <minusSign>-</minusSign>
      <exponential>E</exponential>
      <perMille>‰</perMille>
      <infinity>∞</infinity>
      <nan>☹</nan>
</symbols>
<decimalFormats>
  <decimalFormatLength type="long">
    <decimalFormat>
      <pattern>#,##0.###</pattern>
    </decimalFormat>
  </decimalFormatLength>
</decimalFormats>
<scientificFormats>
  <default type="long">
  <scientificFormatLength type="long">
    <scientificFormat>
      <pattern>0.000###E+00</pattern>
    </scientificFormat>
  </scientificFormatLength>
  <scientificFormatLength type="medium">
    <scientificFormat>
      <pattern>0.00##E+00</pattern>
    </scientificFormat>
  </scientificFormatLength>
</scientificFormats>
<percentFormats>
  <percentFormatLength type="long">
    <percentFormat>
      <pattern>#,##0%</pattern>
    </percentFormat>
  </percentFormatLength>
</percentFormats>
<currencyFormats>
  <currencyFormatLength type="long">
    <currencyFormat>
      <pattern>¤ #,##0.00;(¤ #,##0.00)</pattern>
    </currencyFormat>
  </currencyFormatLength>
</currencyFormats>
<currencies>
    <currency type="USD">
        <displayName>Dollar</displayName>
        <symbol>$</symbol>
    </currency>
    <currency type ="JPY">
        <displayName>Yen</displayName>
        <symbol>¥</symbol>
    </currency>
    <currency type ="INR">
        <displayName>Rupee</displayName>
        <symbol choice="true">0≤Rf|1≤Ru|1<Rf</symbol>
    </currency>
    <currency type="PTE">
        <displayName>Escudo</displayName>
        <symbol>$</symbol>
    </currency>
</currencies>

In formatting currencies, the currency number format is used with the appropriate symbol from <currencies>, according to the currency code. The <currencies> list can contain codes that are no longer in current use, such as PTE. The choice attribute can be used to indicate that the value uses a pattern which is to be interpreted as a ChoiceFormat, with the 0 parameter being the numeric value.

Note: Currency values should never be interchanged without a known currency code. You never want the number 3.5 interpreted as $3.5 by one user and ¥3.5 by another. Locale data contains localization information for currencies, not a currency value for a country. A currency amount logically consists of a numeric value, plus an accompanying ISO 4217 currency code (or equivalent). The currency code may be implicit in a protocol, such as where USD is implicit. But if the raw numeric value is transmitted without any context, then it has no definitive interpretation.

Notice that the currency code is completely independent of the end-user's language or locale. For example, RUR is the code for Russian Rubles. A currency amount of <RUR, 1.23457×10³> would be localized for a Russian user into "1 234,57р." (using U+0440 (р) cyrillic small letter er). For an English user it would be localized into the string "Rub 1,234.57" The end-user's language is needed for doing this last localization step; but that language is completely orthogonal to the currency code needed in the data. After all, the same English user could be working with dozens of currencies. (See for example: NSDSA Currency Table and UNECE Currency Data.) Notice also that the currency code is also independent of whether currency values are inter-converted, which requires more interesting financial processing: the rate of conversion may depend on a variety of factors.

Thus logically speaking, once a currency amount is entered into a system, it should be logically accompanied by a currency code in all processing. This currency code is independent of whatever the user's original locale was. Only in badly-designed software is the currency code (or equivalent) not present, so that the software has to "guess" at the currency code based on the user's locale.

Note: The number of decimal places and the rounding for each currency is not locale-specific data, and is not contained in the localeData format. Those values override whatever is given in the currency numberFormat. For more information, see Supplemental Data.

For background information on currency names, see Currency Names.

<collations>

This section contains one or more collation elements, distinguished by type. Each collation contains rules that specify a certain sort-order, as a tailoring of the UCA table. (For a chart view of the UCA, see Collation Chart.) This syntax is an XMLized version of the Java/ICU syntax. For illustration, the rules are accompanied by the corresponding basic ICU rule syntax (used in ICU and Java) and/or the ICU parameterizations, and the basic syntax may be used in examples.

Note: ICU provides a concise format for specifying orderings, based on tailorings to the UCA. For example, to specify that k and q follow 'c', one can use the rule: "& c < k < q". The rules also allow people to set default general parameter values, such as whether uppercase is before lowercase or not. (Java contains an earlier version of ICU, and has not been updated recently. It does not support any of the basic syntax marked with [...], and its default table is not the UCA.)

However, it is not necessary for ICU to be used in the underlying implementation. The features are simply related to the ICU capabilities, since that supplies more detailed examples. Note: there is an on-line demonstration of collation at Locale Explorer (pick the locale and scroll to "Collation Rules").

Like the ICU rules, the tailoring syntax is designed to be independent of the actual weights used in any particular UCA table. That way the same rules can be applied to UCA versions over time, even if the underlying weights change. The following describes the overall document structure of a collation:

<collation>
 <uca version='3.1.1'>
 <settings caseLevel="on"/>
 <rules>
  <!-- rules go here -->
 </rules>
</collation>

Version

The version is used in case a specific version of the UCA is to be specified. It must be specified if the results are to be identical on different systems. If it is not supplied, then the version is assumed to be the same as the Unicode version for the system as a whole.

Note: For version 3.1.1 of the UCA, the version of Unicode must also be specified with any versioning information. This has been changed as of the last UTC meeting, so that it will no longer be necessary as of UCA 4.0. So it is omitted here.

Setting Options

In XML, these are attributes of <settings>. For example, <setting strength="secondary"> will only compare strings based on their primary and secondary weights.

If the attribute is not present, the default (or for the base url's attribute, if there is one) is used. The default is listed in italics. The effect of these are defined by reference to the ICU rule syntax).

Collation Settings Attributes
Attribute Options Basic Example   XML Example Description
strength primary (1)
secondary (2)
tertiary (3)
quarternary (4)
identical (5)
[strength 1] strength = "primary" Sets the default strength for comparison, as described in the UCA.
alternate non-ignorable
shifted
[alternate non-ignorable] alternate = "non-ignorable" Sets alternate handling for variable weights, as described in UCA
backwards on
off
[backwards on]   backwards = "on" Sets the comparison to be backwards ("French"), as s described in UCA
normalization on
off
[normalization on]  normalization = "off" If on, then the normal UCA algorithm is used. If off, then all strings that are in FCD will sort correctly, but others won't. So should only be set off if the the strings to be compared are in FCD.
caseLevel on
off
[caseLevel on] caseLevel = "off" If set to on, a level consisting only of case characteristics will be inserted in front of tertiary level. To ignore accents but take cases into account, set strength to primary and case level to on
caseFirst upper
lower
off
[caseFirst off] caseFirst = "off" If set to upper, causes upper case to sort before lower case. If set to lower, lower case will sort before upper case. Useful for locales that have already supported ordering but require different order of cases. Affects case and tertiary levels.
hiraganaQ on
off
[hiraganaQ on] hiragana­Quarternary = "on" Controls special treatment of Hiragana code points on quaternary level. If turned on, Hiragana codepoints will get lower values than all the other non-variable code points. The strength must be greater or equal than quaternary if you want this attribute to take effect.

Collation Rule Syntax

The goal for the collation rule syntax is to have clearly expressed rules with a concise format, that parallels the Basic syntax as much as possible.  The rule syntax uses abbreviated element names for primary (level 1), secondary (level 2), tertiary (level 3), and identical, to be as short as possible. The reason for this is because the tailorings for CJK characters are quite large (tens of thousands of elements), and the extra overhead would have been considerable. Other elements and attributes do not occur as frequently, and have longer names.

Note: The rules are stated in terms of actions that cause characters to change their ordering relative to other characters. This is for stability; assigning characters specific weights would not work, since the exact weight assignment in UCA (or ISO 14651) is not required for conformance -- only the relative ordering of the weights. In addition, stating rules in terms of relative order is much less sensitive to changes over time in the UCA itself.

Orderings

The following are the normal ordering actions used for the bulk of characters. Each rule contains a string of ordered characters that starts with an anchor point or a reset value. The reset value is an absolute point in the UCA that determines the order of other characters. For example, the rule & a < g, places "g" after "a" in a tailored UCA: the "a" does not change place. Logically, subsequent rule after a reset indicates a change to the ordering (and comparison strength) of the characters in the UCA. For example, the UCA has the following sequence (abbreviated for illustration):

... a <3 a <3 ⓐ <3 A <3 A <3 Ⓐ <3 ª <2 á <3 Á <1 æ <3 Æ <1 ɐ <1 ɑ <1 ɒ <1 b <3 b <3 ⓑ <3 B <3 B <3 ℬ ...

Whenever a character is inserted into the UCA sequence, it is inserted at the first point where the strength difference will not disturb the other characters in the UCA. For example, & a < g puts g in the above sequence with a strength of L1. Thus the g must go in after any lower strengths,  as follows:

... a <3 a <3 ⓐ <3 A <3 A <3 Ⓐ <3 ª <2 á <3 Á <1 g <1 æ <3 Æ <1 ɐ <1 ɑ <1 ɒ <1 b <3 b <3 ⓑ <3 B <3 B <3 ℬ ...

The rule & a << g, which uses a level-2 strength, would produce the following sequence:

... a <3 a <3 ⓐ <3 A <3 A <3 Ⓐ <3 ª <2 g <2 á <3 Á <1 æ <3 Æ <1 ɐ <1 ɑ <1 ɒ <1 b <3 b <3 ⓑ <3 B <3 B <3 ℬ ...

And the rule & a <<< g, which uses a level-3 strength, would produce the following sequence:

... a <3 g <3 a <3 ⓐ <3 A <3 A <3 Ⓐ <3 ª <2 á <3 Á <1 æ <3 Æ <1 ɐ <1 ɑ <1 ɒ <1 b <3 b <3 ⓑ <3 B <3 B <3 ℬ ...

Since resets always work on the existing state, the rule entries must be are in the proper order. A character or sequence may occur multiple times; each subsequent occurrence causes a different change. The following shows the result of serially applying a three rules.

  Rules   Result Comment  
1 & a < g ... a <1 g ... Put g after a.
2 & a < h < k ... a <1 h <1 k <1 g ... Now put h and k after a (inserting before the g).
3 & h << g ... a <1 h <1 g <1 k ... Now put g after h (inserting before k).

Notice that characters can occur multiple times, and thus override previous rules.

Specifying Collation Ordering
Basic Symbol Basic Example XML Symbol XML Example Description
&   & Z   <reset> <reset>Z</reset> Don't change the ordering of Z, but place subsequent characters relative to it.
<   & a
< b  
<p> <reset>a<reset>
<p>b</p>
Make 'b' sort after 'a', as a primary (base-character) difference
<<   & a
<< ä  
<s> <reset>a<reset>
<s>ä</s>
Make 'ä' sort after 'a' as a secondary (accent) difference
<<<   & a
<<< A  
<t> <reset>a<reset>
<t>A</t>
Make 'A' sort after 'a' as a secondary (accent) difference
=   & x
= y  
<i> <reset>v<reset>
<i>w</i>
Make 'w' sort identically to 'v'

Resets only need to be at the start of a sequence, to position the characters relative a character that is in the UCA (or has already occurred in the tailoring). For example: <reset>z</reset><p>a</p><p>b</p><p>c</p><p>d</p>.

Some additional elements are provided to save space with large tailorings. The addition of a 'c' to the element name indicates that each of the characters in the contents of that element are to be handled as if they were separate elements with the corresponding strength:

Abbreviating Ordering Specifications
XML Symbol XML Example Equivalent
<pc> <pc>bcd</pc> <p>b</p><p>c</p><p>d</p>
<sc> <sc>àáâã</sc> <s>à</s><s>á</s><s>â</s><s>ã</s>
<tc> <tc>PpP</tc> <t>P</t><t>p</t><t>P</t>
<ic> <ic>VwW</ic> <i>V</i><i>w</i><i>W</i>

Escaping Characters

Unfortunately, XML does not have the capability to contain all Unicode code points. Due to this, extra syntax is required to represent those code points that cannot be otherwise represented. This corresponds to the quoting mechanism used in the basic syntax. This also must be used where spaces are significant (otherwise they are stripped).

Excaping Characters
Basic Example XML Example
'\u0000' <cp hex="0">

Note: If XML 1.1 is approved in the current state, then this would not be necessary -- except for NULL (U+0000), which is typically never tailored.

Contractions

To sort a sequence as a single item (contraction), just use the sequence, e.g.

Specifying Contractions
BASIC Example XML Example Description
& k
< ch
<reset>k<reset>
<p>ch</p>
Make the sequence 'ch' sort after 'k', as a primary (base-character) difference

Expansions

There are two ways to handle expansions (where a character sorts as a sequence) with both the basic syntax and the XML syntax. The first method is to reset to the sequence of characters. The second is to use the extension sequence. Both are equivalent in practice (unless the reset sequence happens to be a contraction).

Specifying Expansions
Basic XML Description
& ch
< k
<reset>ch</reset>
<p>k</p>
Make 'k' sort after the sequence 'ch'; thus 'k' will behave as if it expands to a character after 'c' followed by an 'h'. (unless 'ch' is defined beforehand as a contraction).
& c 
< k / h
<reset>c</reset>
<p>k<extend>h</extend></p>
Make 'k' sort after the sequence 'ch'; thus 'k' will behave as if it expands to a character after 'c' followed by an 'h'.

Context Before

The context before a character can affect how it is ordered, such as in Japanese. This could be expressed with a combination of contractions and expansions, but is faster using a context. (The actual weights produced are different, but the resulting string comparisons are the same.)

Specifying Previous Context
Basic XML
&[before 3] ァ
<<< ァ|ー
= ァ |ー
= ぁ|ー
<reset before="tertiary">ァ</reset>
<s>ァ<context>ー</context></s>
<i>ァ<context>ー</context></i>
<i>ぁ<context>ー</context></i>

Placing Characters Before Others

There are certain circumstances where characters need to be placed before a given character, rather than after. This is the case with Pinyin, for example, where certain accented letters are positioned before the base letter. That is accomplished with the following syntax.

Placing Characters Before Others
Item Options Basic Example   XML Example
before  primary
secondary
tertiary
identical
& [before 1] a
<< à
<reset before="primary">a</reset>
<s>à</s>

Logical Reset Positions

The UCA has the following overall structure for weights, going from low to high.

Specifying Logical Positions
Name Description UCA Examples
first tertiary ignorable
...
last tertiary ignorable
p, s, t = ignore Control Codes
Format Characters
Hebrew Points
Tibetan Signs
...
first secondary ignorable
...
last secondary ignorable
p, s = ignore None in UCA
first primary ignorable
...
last primary ignorable
p = ignore Most combining marks
first variable
...
last variable
if alternate = non-ignorable
p != ignore,
if alternate = shifted
p, s, t = ignore
Whitespace,
Punctuation,
Symbols
first non-ignorable
...
last non-ignorable
p != ignore Small number of exceptional symbols
[e.g. U+02D0 MODIFIER LETTER TRIANGULAR COLON]
Numbers
Latin
Greek
...
implicits p != ignore, assigned automatically CJK, CJK compatibility (those that are not decomposed)
CJK Extension A, B
Unassigned
first trailing
...
last trailing
p != ignore,
used for trailing syllable components
Jamo Trailing
Jamo Leading

Each of the above Names (except implicits) can be used with a reset to position characters relative to that logical position. That allows characters to be ordered before or after a logical position rather than a specific character.

Note: The reason for this is so that tailorings can be more stable. A future version of the UCA might add characters at any point in the above list. Suppose that you set character X to be after Y. It could be that you want X to come after Y, no matter what future characters are added; or it could be that you just want Y to come after a given logical position, e.g. after the last primary ignorable.

Here is an example of the syntax:

Sample Logical Position
Basic XML
& [first tertiary ignorable]
<< à 
<reset><first_tertiary_ignorable/></reset>
<s>à</s>

For example, to make a character be a secondary ignorable, one can make it be immediately after (at a secondary level) a specific character (like a combining dieresis), or one can make it be immediately after the last secondary ignorable.

The last-variable element indicates the "highest" character that is treated as punctuation with alternate handling. Unlike the other logical positions, it can be reset as well as referenced. For example, it can be reset to be just above spaces if all visible punctuation are to be treated as having distinct primary values.

Specifying Last-Variable
Attribute Options Basic Example   XML Example
variableTop at & x
= [last variable]
<reset>x</reset>
<i><last_variable/></i>
after & x
< [last variable]
<reset>x</reset>
<p><last_variable/></p>
before & [before 1] x
< [last variable]
<reset before="primary">x</reset>
<p><last_variable/></p>

The default value for variable-top depends on the UCA setting. For example, in 3.1.1, the value is at:

U+1D7C3 MATHEMATICAL SANS-SERIF BOLD ITALIC PARTIAL DIFFERENTIAL

Special-Purpose Commands

The suppress contractions tailoring command turns off any existing contractions that begin with those characters. It is typically used to turn off the Cyrillic contractions in the UCA, since they are not used in many languages and have a considerable performance penalty. The argument is a Unicode Set, with syntax as in UnicodeSet.

The optimize tailoring command is purely for performance. It indicates that those characters are sufficiently common in the target language for the tailoring that their performance should be enhanced.

Special-Purpose Commands
Basic XML
[suppress contractions [Љ-ґ]] <suppress_contractions>[Љ-ґ]</suppressContractions
[optimize [Ά-ώ]] <optimize>[Ά-ώ]</optimize>


Example:

The following is a simple example that takes portions of the Swedish tailoring plus part of a Japanese tailoring, for illustration. For more complete examples, see the actual locale data: Japanese, Chinese, Swedish, Traditional German are particularly illustrative.

<collation>
  <base UCA='3.1.1'>
  <settings caseLevel="on"/>
  <rules>
        <reset>Z</reset>
        <p>æ</p>
        <t>Æ</t>
        <p>å</p>
        <t>Å</t>
        <t>aa</t>
        <t>aA</t>
        <t>Aa</t>
        <t>AA</t>
        <p>ä</p>
        <t>Ä</t>
        <p>ö</p>
        <t>Ö</t>
        <s>ű</s>
        <t>Ű</t>
        <p>ő</p>
        <t>Ő</t>
        <s>ø</s>
        <t>Ø</t>
        <reset>V</reset>
        <tc>wW</tc>
        <reset>Y</reset>
        <tc>üÜ</tc>
        <reset><last_non_ignorable/></reset>
        <!-- following is equivalent to <p>亜</p><p>唖</p><p>娃</p>... -->
        <pc>亜唖娃阿哀愛挨姶逢葵茜穐悪握渥旭葦芦</pc>
        <pc>鯵梓圧斡扱</pc>
  </rules>
</collation>

Appendix A: Sample Special Elements

The following are nonstandard elements provided as examples.

ICU

There are three main areas where ICU has capabilies that go beyond what is shown above.

<ruleBasedNumberFormat>

The rule-based number format (RBNF) encapsulates a set of rules for mapping binary numbers to and from a readable representation. They are typically used for spelling out numbers, but can also be used for other number systems like roman numerals, or for ordinal numbers (1st, 2nd, 3rd,...). The rules are fairly sophisticated; for details see Rule-Based Number Format.

Example:

<special xmlns="http://oss.software.ibm.com/icu">
  <ruleBasedNumberFormats>
    <ruleBasedNumberFormat type="spellout">
                %%and:
                    and =%default=;
                    100: =%default=;
                %%commas:
                    ' and =%default=;
                    100: , =%default=;
                    1000: , 
    </ruleBasedNumberFormat>
    <ruleBasedNumberFormat type="ordinal">
                %main:
                    =#,##0==%%abbrev=;
                %%abbrev:
                    th; st; nd; rd; th;
                    20: &gt;&gt;;
                    100: &gt;&gt;;
    </ruleBasedNumberFormat>
    <ruleBasedNumberFormat type="duration">
            %with-words:
                0 seconds; 1 second; =0= seconds;
                60/60: 
    </ruleBasedNumberFormat>
  </special>

<boundaries>

Boundaries provide rules for grapheme-cluster ("user-character"), word, line, and sentence breaks. This format is the Java/ICU syntax, at the top level. For a description of that, see RBBI Rule Syntax. (The format will be moved into the ICU User Guide soon.) The enclosing special element is a sub-element of <localeData>.

<localeData>
...
  <special xmlns="http://oss.software.ibm.com/icu">
    <boundaries>
      <grapheme class="RuleBased" append="true">
        <!-- in addition to the normal rules, treat CH and RR as graphemes. -->
        [cC][hH];[rR][rR];
      </grapheme>
      <word class="Dictionary" import="thaiDict.dat" append="true">
        <!-- When doing Thai word break, check the normal word break rules first. -->
        digit=[[:Nd:][:No:]];
        $digit [[:Pd:]­‧&apos;.]
      </word>
    </boundaries>
  </special>
</localeData>

<transforms>

There may be language-specific transformations, typically used in locale data for transliterations. Such transformations require far more than a simple list of matching characters, since the matches are highly context-sensitive. Each such transform is supplied in a <transform> element. The contents of the transform element is a list of rules, as described in the ICU documentation for Transforms. The enclosing special element is a sub-element of <localeData>. The target value is either a script (long or short name) or a locale id.

Note: there is an on-line demonstration of transforms at Transforms Demo.

Example: The following is an abbreviated example for Greek to Latin, in a Greek locale. The target value can be a script ID or a locale ID.

<localeData>
...
  <special xmlns="http://oss.software.ibm.com/icu">
    <transforms>
      <transform type="Latin">
::NFD (NFC) ; # convert everything to decomposed for simplicity
...
α  a ;  Α  A ;
β  v ;  Β  V ;
γ } $gammaLike  n } $egammaLike ;
Γ } $gammaLike  N } $egammaLike ;
γ  g ;  Γ  G ;
δ  d ;  Δ  D ;
ε  e ;  Ε  E ;
ζ  z ;  Ζ  Z ;
Θ } $beforeLower  Th ;
θ  th ;  Θ  TH ;
ι  i ;  Ι  I ;
κ  k ;  Κ  K ;
λ  l ;  Λ  L ;
μ  m ; Μ  M ;
ν } $gammaLike  n\' ;
Ν } $gammaLike  N\' ;
ν  n ; Ν  N ;
...
::NFC (NFD) ; # convert back to composed
      </transform>
    </transforms>
  </special>
</localeData>

openoffice.org

A number of the elements above can have extra information for openoffice.org, such as the following example:

<numberFormat type="currency">
  <special xmlns="http://www.openoffice.org" msgid="FixedFormatstype9" usage="FIXED_NUMBER" formatindex="4" />
  <pattern type="positive">¤ #,##0.00;</pattern>
  <pattern type="negative">(¤ #,##0.00)</pattern>
</numberFormat>

POSIX

This is a sample of old POSIX abbreviations for pre-GUI days:

<localeData>
...
  <special xmlns="http://www.opengroup.org/regproducts/xu.htm">
    <messages>
      <no>No</no>
      <yes>Yes</yes>
      <shortYes>Y</shortYes>
      <shortNo>N</shortNo>
    </messages>
  </special>
</localeData>

ISO TR 14652

The following is ISO TR 14652 compatibility data. This section is here because portions of TR 14652 data may used in LINUX distributions and other systems.

Note: 14652 is a Type 1 TR: "when the required support cannot be obtained for the publication of an International Standard, despite repeated effort". See the ballot comments on 14652 Comments for details on the 14652 defects. For example, most of these patterns make little provision for substantial changes in format when elements are empty, so are not particularly useful in practice. Compare, for example, the mail-merge capabilities of production software such as Microsoft Word or OpenOffice.

Examples:

<localeData>
...
  <special xmlns="http://anubis.dkuug.dk/jtc1/sc22/wg20/docs/n897-14652w25.pdf">
    <iso14652>
            <addressFormat>
                <postalPattern>"%n%N%a%N%d%N%f%N%b%N%h %s%N%e %r%N%l%N%C-%z %T%, %S %z%N%c%N"</postalPattern>
            </addressFormat>

            <nameFormat>
                <namePattern>%p%t%g%m%t%f</namePattern>
                <generalSalutation></generalSalutation>
                <shortSalutationMr> Mr.</shortSalutationMr>
                <shortSalutationMiss>Ms.</shortSalutationMiss>
                <shortSalutationMrs>Mrs.</shortSalutationMrs>
                <longSalutationMr> Mister.</longSalutationMr>
                <longSalutationMiss>Miss</longSalutationMiss>
                <longSalutationMrs>Mrs.</longSalutationMrs>
            </nameFormat>

            <identification>
                <!-- Identification of the person who produced the data file. -->
                <title></title>
                <source></source>
                <address></address>
                <contact></contact>
                <email></email>
                <telephone></telephone>
                <fax></fax>
                <languageUsed></languageUsed>
                <country></country>
                <audience></audience>
                <application></application>
                <abbreviation></abbreviation>
                <revision></revision>
                <date></date>
            </identification>

            <telephoneFormat>
                <internationalPattern>+%c (%a)%t-%l</internationalPattern>
                <domesticPattern>(%a)%t-%l</domesticPattern>
                <internationalDialCode>001 </internationalDialCode>
                <internationalPrefix> </internationalPrefix>
            </telephoneFormat>

            <countryInfo>
              <countryPost>US</countryPost>
              <countryCar>US</countryCar>
              <countryNumber type="666"/>
              <countryISBNNumber type="666"/>
            </countryInfo>
    </iso14652>
  </special>
<localeData>

Appendix B: Transmitting Locale Information

In a world of on-demand software components, with arbitrary connections between those components, it is important to get a sense of where localization should be done, and how to transmit enough information so that it can be done at that appropriate place. End-users need to get messages localized to their languages, messages that not only contain a translation of text, but also contain variables such as date, time, number formats, and currencies formatted according to the users' conventions. The strategy for doing the so-called JIT localization is made up of two parts:

  1. Store and transmit neutral-format data wherever possible.
  2. Localize that data as "close" to the end-user as possible.

There are a number of advantages to this strategy. The longer the data is kept in a neutral format, the more flexible the entire system is. On a practical level, if transmitted data is neutral-format, then it is much easier to manipulate the data, debug the processing of the data, and maintain the software connections between components.

Once data has been localized into a given language, it can be quite difficult to programmatically convert that data into another format, if required. This is especially true if the data contains a mixture of translated text and formatted variables. Once information has been localized into, say, Romanian, it is much more difficult to localize that data into, say, French. Parsing is more difficult than formatting, and may run up against different ambiguities in interpreting text that has been localized, even if the original translated message text is available (which it may not be).

Moreover, the closer we are to end-user, the more we know about that user's preferred formats. If we format dates, for example, at the user's machine, then it can easily take into account any customizations that the user has specified. If the formatting is done elsewhere, either we have to transmit whatever user customizations are in play, or we only transmit the user's locale code, which may only approximate the desired format. Thus the closer the localization is to the end user, the less we need to ship all of the user's preferences arond to all the places that localization could possibly need to be done.

Even though localization should be done as close to the end-user as possible, there will be cases where different components need to be aware of whatever settings are appropriate for doing the localization. Thus information such as a locale code or timezone needs to be communicated between different components.

Message Formatting and Exceptions

Windows (FormatMessage, String.Format), Java (MessageFormat) and ICU (MessageFormat, umsg) all provide methods of formatting variables (dates, times, etc) and inserting them at arbitrary positions in a string. This avoids the manual string concatenation that causes severe problems for localization. The question is, where to do this? It is especially important since the original code site that originates a particular message may be far down in the bowels of a component, and passed up to the top of the component with an exception. So we will take that case as representative of this class of issues.

There are circumstances where the message can be communicated with a language-neutral code, such as a numeric error code or mnemonic string key, that is understood outside of the component. If there are arguments that need to accompany that message, such as a number of files or a datetime, those need to accompany the numeric code so that when the localization is finally at some point, the full information can be presented to the end-user. This is the best case for localization.

More often, the exact messages that could originate from within the component are not known outside of the component itself; or at least they may not be known by the component that is finally displaying text to the user. In such a case, the information as to the user's locale needs to be communicated in some way to the component that is doing the localization. That locale information does not necessarily need to be communicated deep within the component; ideally, any exceptions should bundle up some language-neutral message ID, plus the arguments needed to format the message (e.g. datetime), but not do the localization at the throw site. This approach has the advantages noted above for JIT localization.

In addition, exceptions are often caught at a higher level; they don't end up being displayed to any end-user at all. By avoiding the localization at the throw site, it the cost of doing formatting, when that formatting is not really necessary. In fact, in many running programs most of the exceptions that are thrown at a low level never end up being presented to an end-user, so this can have considerable performance benefits.

Appendix C: Supplemental Data

The following represents the format for supplemental information. This is information that is important for proper formatting, but is not contained in the locale hierarchy, and is not overridden by locale data. It uses the following format, where the data is solely for illustration:

<supplementalData>
  <currencyData>
    <fractions>
      <currency iso4217="CHF" rounding="5"/>
      <currency iso4217="ITL" digits="0"/>
      <currency iso4217="FOO" digits="0" rounding="5"/>
    </fractions>
    <region iso3166="IT"> <!-- Italy -->
      <currency iso4217="EUR"/>
      <currency iso4217="EUR" before="2002-01-01">
        <alternate iso4217="ITL"/>
      </currency>
      <currency iso4217="ITL" before="2000-01-01"/>
    </region>
    <region iso3166="ET"> <!-- Ethiopia -->
       ...
      <region iso4217="ITL" before="1945-03-01"/> 
    </region>
    <region iso3166="DE"> <!-- Germany -->
      <currency iso4217="EUR"/>
       ...
    </region>
    <region iso3166="US"> <!-- USA -->
      <currency iso4217="USD"/>
    </region>
    <region iso3166="EC"> <!-- Ecuador -->
      <currency iso4217="USD"/>
      <currency iso4217="ECS" before="2000-01-01"/>
       ...
    </region>
    <region iso3166="CH"> <!-- Switzerland -->
      <currency iso4217="CHF"/>
    </region>
  </currencyData>
</supplementalData>

The only data currently represented is currency data. Each currencyData element contains one fractions element followed by one or more region elements. The fractions element contains any number of currency elements, with the following attributes:

Each region element contains one attribute:

And can have any number of currency elements, with the following attributes. (Each currency element can also contain zero or more alternate elements. These are a list of alternate currencies, in preference order.)

Each before value governs the time up to the previous before value. That is, suppose that we have the following data for the region code R.

  <region iso3166="R">
    <currency iso4217="C01" before="1942"/>
    <currency iso4217="C02"/>
    <currency iso4217="C03" before="1927"/>
    <currency iso4217="none" before="1937-02-13"/>
  </region>

Logically, the currency elements are treated in sorted order, according to the before value. If default value for the before element is logically +∞. This results in the following mapping for region R, using a set of half-open intervals:

Currency

Condition (based on time t)

C02

1942-01-01 00:00:00 GMT

≤ t ≤

+∞

C01

1937-02-13 00:00:00 GMT

t <

1942-01-01 00:00:00 GMT

C03

1927-01-01 00:00:00 GMT

t <

1937-02-13 00:00:00 GMT

XXX

-∞

t <

1927-01-01 00:00:00 GMT

Open issue: We should supply information for mapping locales to a normalized version, thus en_Latin_US would normalize to en_US.

Appendix D: Language and Locale IDs

People have very slippery notions of what distinguishes a language code vs. a locale code. The problem is that both are somewhat nebulous concepts.

In practice, many people use RFC 3066 codes to mean locale codes instead of strictly language codes. It is easy to see why this came about; because RFC 3066 includes an explicit region (territory) code, for most people it was sufficient for use as a locale code as well. For example, when typical web software receives an RFC 3066 code, it will use it as a locale code. Other typical software will do the same: in practice, language codes and locale codes are treated interchangeably. Some people recommend distinguishing on the basis of "-" vs "_" (e.g. zh-TW for language code, zh_TW for locale code), but in practice that does not work because of the free variation out in the world in the use of these separators. Notice that Windows, for example, uses "-" as a separator in its locale codes. So pragmatically one is forced to treat "-" and "_" as equivalent when interpreting either one on imput.

Another reason for the conflation of these codes is that very little data in most systems is distinguished by region alone; currency codes and measurement systems being some of the few. Sometimes date or number formats are mentioned as regional, but that really doesn't make much sense. If people see the sentence "You will have to adjust the value to १,२३४.५६७ from ૭૧,૨૩૪.૫૬" (using Indic digits), they would say that sentence is simply not English. Number format is far more closely associated with language than it is with region. The same is true for date formats: people would never expect to see intermixed a date in the format "2003年4月1日" (using Kanji) in text purporting to be purely English. There are regional differences in date and number format — differences which can be important — but those are different in kind than other language differences between regions.

Notice also that currency codes are different than currency localizations. The currency localizations should normally be in the language-based resource bundles, not in the territory-based resource bundles. Thus, the resource bundle en contains the localized mappings in English for a range of different currency codes: USD => $, RUR => Rub, etc. (In protocols, the currency codes should always accompany any currency amounts; otherwise the data is ambiguous, and software is forced to use the user's territory to guess at the currency. For some informal discussion of this, see JIT Localization.)

Written Language

Criteria for what makes a written language should be purely pragmatic; what would copy-editors say? If one gave them text like the following, they would respond that is far from acceptable English for publication, and ask for it to be redone:

  1. "Theatre Center News: The date of the last version of this document was 2003年3月20日. A copy can be obtained for $50,0 or 1.234,57 грн. We would like to acknowledge contributions by the following authors (in alphabetical order): Alaa Ghoneim, Behdad Esfahbod, Ahmed Talaat, Eric Mader, Asmus Freytag, Avery Bishop, and Doug Felt."

So one would change it to either B or C below, depending on which orthographic variant of English was the target for the publication:

  1. "Theater Center News: The date of the last version of this document was 3/20/2003. A copy can be obtained for $50.00 or 1,234.57 Ukrainian Hryvni. We would like to acknowledge contributions by the following authors (in alphabetical order): Alaa Ghoneim, Ahmed Talaat, Asmus Freytag, Avery Bishop, Behdad Esfahbod, Doug Felt, Eric Mader."

  2. "Theatre Centre News: The date of the last version of this document was 20/3/2003. A copy can be obtained for $50.00 or 1,234.57 Ukrainian Hryvni. We would like to acknowledge contributions by the following authors (in alphabetical order): Alaa Ghoneim, Ahmed Talaat, Asmus Freytag, Avery Bishop, Behdad Esfahbod, Doug Felt, Eric Mader."

Clearly there are many acceptable variations on this text. For example, copy editors might still quibble with the use of first vs. last name sorting in the list, but clearly the first list was not acceptable English alphabetical order. And in quoting a name, like "Theatre Centre News", one may leave it in the source orthography even if it differs from the publication target orthography. And so on. However, just as clearly, there limits on what is acceptable English, and "2003年3月20日", for example, is not.

Copyright and Permission Notice

Copyright (c) 2002-2003 International Business Machines Corporation and others. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of the LDML format and associated documentation files (the "Format"), to deal in the Format without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Format, and to permit persons to whom the Format is furnished to do so, provided that both the above copyright notice(s) and this permission notice appear in supporting documentation.

THE FORMAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS FORMAT.

Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Format without prior written authorization of the copyright holder.


All trademarks and registered trademarks mentioned herein are the property of their respective owners.