1## Unicode Technical Standard #35 2 3# Unicode Locale Data Markup Language (LDML)<br/>Part 6: Supplemental 4 5|Version|45 | 6|-------|-----------| 7|Editors|Steven Loomis (<a href="mailto:[email protected]">[email protected]</a>) and <a href="tr35.md#Acknowledgments">other CLDR committee members| 8 9For the full header, summary, and status, see [Part 1: Core](tr35.md). 10 11### _Summary_ 12 13This document describes parts of an XML format (_vocabulary_) for the exchange of structured locale data. This format is used in the [Unicode Common Locale Data Repository](https://www.unicode.org/cldr/). 14 15This is a partial document, describing only those parts of the LDML that are relevant for supplemental data. For the other parts of the LDML see the [main LDML document](tr35.md) and the links above. 16 17_Note:_ 18Some links may lead to in-development or older 19versions of the data files. 20See <https://cldr.unicode.org> for up-to-date CLDR release data. 21 22### _Status_ 23 24<!-- _This is a draft document which may be updated, replaced, or superseded by other documents at any time. 25Publication does not imply endorsement by the Unicode Consortium. 26This is not a stable document; it is inappropriate to cite this document as other than a work in progress._ --> 27 28_This document has been reviewed by Unicode members and other interested parties, and has been approved for publication by the Unicode Consortium. 29This is a stable document and may be used as reference material or cited as a normative reference by other specifications._ 30 31> _**A Unicode Technical Standard (UTS)** is an independent specification. Conformance to the Unicode Standard does not imply conformance to any UTS._ 32 33_Please submit corrigenda and other comments with the CLDR bug reporting form [[Bugs](tr35.md#Bugs)]. Related information that is useful in understanding this document is found in the [References](tr35.md#References). For the latest version of the Unicode Standard see [[Unicode](tr35.md#Unicode)]. For a list of current Unicode Technical Reports see [[Reports](tr35.md#Reports)]. For more information about versions of the Unicode Standard, see [[Versions](tr35.md#Versions)]._ 34 35## <a name="Parts" href="#Parts">Parts</a> 36 37The LDML specification is divided into the following parts: 38 39* Part 1: [Core](tr35.md#Contents) (languages, locales, basic structure) 40* Part 2: [General](tr35-general.md#Contents) (display names & transforms, etc.) 41* Part 3: [Numbers](tr35-numbers.md#Contents) (number & currency formatting) 42* Part 4: [Dates](tr35-dates.md#Contents) (date, time, time zone formatting) 43* Part 5: [Collation](tr35-collation.md#Contents) (sorting, searching, grouping) 44* Part 6: [Supplemental](tr35-info.md#Contents) (supplemental data) 45* Part 7: [Keyboards](tr35-keyboards.md#Contents) (keyboard mappings) 46* Part 8: [Person Names](tr35-personNames.md#Contents) (person names) 47* Part 9: [MessageFormat](tr35-messageFormat.md#Contents) (message format) 48 49## <a name="Contents" href="#Contents">Contents of Part 6, Supplemental</a> 50 51* Introduction [Supplemental Data](#Supplemental_Data) 52* [Territory Data](#Territory_Data) 53 * [Supplemental Territory Containment](#Supplemental_Territory_Containment) 54 * [Subdivision Containment](#Subdivision_Containment) 55 * [Supplemental Territory Information](#Supplemental_Territory_Information) 56 * [Territory-Based Preferences](#Territory_Based_Preferences) 57 * [Preferred Units for Specific Usages](#Preferred_Units_For_Usage) 58 * [`<rgScope>`: Scope of the “rg” Locale Key](#rgScope) 59* [Supplemental Language Data](#Supplemental_Language_Data) 60* [Supplemental Language Grouping](#Supplemental_Language_Grouping) 61* [Supplemental Code Mapping](#Supplemental_Code_Mapping) 62* ~~[Telephone Code Data](#Telephone_Code_Data)~~ (Deprecated) 63* ~~[Postal Code Validation (Deprecated)](#Postal_Code_Validation)~~ 64* [Supplemental Character Fallback Data](#Supplemental_Character_Fallback_Data) 65* [Coverage Levels](#Coverage_Levels) 66 * [Definitions](#Coverage_Level_Definitions) 67 * [Data Requirements](#Coverage_Level_Data_Requirements) 68 * [Default Values](#Coverage_Level_Default_Values) 69* [Supplemental Metadata](#Appendix_Supplemental_Metadata) 70 * [Supplemental Alias Information](#Supplemental_Alias_Information) 71 * Table: [Alias Attribute Values](#Alias_Attribute_Values) 72 * ~~[Supplemental Deprecated Information (Deprecated)](#Supplemental_Deprecated_Information)~~ 73 * [Default Content](#Default_Content) 74* [Locale Metadata Elements](#Metadata_Elements) 75* [Version Information](#Version_Information) 76* [Parent Locales](#Parent_Locales) 77* [Unit Conversion](#Unit_Conversion) 78 * [Unit Parsing Data](#unit-parsing-data) 79 * [Unit Prefixes](#unit-prefixes) 80 * [Constants](#constants) 81 * [Conversion Data](#conversion-data) 82 * [Derived Unit System](#derived-unit-system) 83 * [Conversion Mechanisms](#conversion-mechanisms) 84 * [Exceptional Cases](#exceptional-cases) 85 * [Identities](#identities) 86 * [Aliases](#aliases) 87 * [“Duplicate” Units](#duplicate-units) 88 * [Discarding Offsets](#discarding-offsets) 89 * [Unresolved Units](#unresolved-units) 90* [Quantities and Base Units](#quantities-and-base-units) 91 * [UnitType vs Quantity](#unittype-vs-quantity) 92 * [Unit Identifier Normalization](#Unit_Identifier_Normalization) 93* [Mixed Units](#mixed-units) 94* [Testing](#testing) 95* [Unit Preferences](#Unit_Preferences) 96 * [Unit Preferences Overrides](#Unit_Preferences_Overrides) 97 * [Compute override units](#compute-override-units) 98 * [Compute regions](#compute--regions) 99 * [Compute the category](#compute-the-category) 100 * [Unit Preferences Data](#Unit_Preferences_Data) 101 * [Examples:](#examples) 102 * [Compute the preferred output unit](#compute-the-preferred-output-unit) 103 * [Search the ranked units](#search-the-ranked-units) 104 * [Constraints](#constraints) 105 * [Examples](#examples) 106* [Unit APIs](#unit-apis) 107 108## Introduction <a name="Supplemental_Data" href="#Supplemental_Data">Supplemental Data</a> 109 110The following represents the format for additional supplemental information. This is information that is important for internationalization and proper use of CLDR, but is not contained in the locale hierarchy. It is not localizable, nor is it overridden by locale data. The current CLDR data can be viewed in the [Supplemental Charts](https://unicode-org.github.io/cldr-staging/charts/38/supplemental/index.html). 111 112```xml 113<!ELEMENT supplementalData (version, generation?, cldrVersion?, currencyData?, territoryContainment?, subdivisionContainment?, languageData?, territoryInfo?, postalCodeData?, calendarData?, calendarPreferenceData?, weekData?, timeData?, measurementData?, unitPreferenceData?, timezoneData?, characters?, transforms?, metadata?, codeMappings?, parentLocales?, likelySubtags?, metazoneInfo?, plurals?, telephoneCodeData?, numberingSystems?, bcp47KeywordMappings?, gender?, references?, languageMatching?, dayPeriodRuleSet*, metaZones?, primaryZones?, windowsZones?, coverageLevels?, idValidity?, rgScope?) > 114``` 115 116The data in CLDR is presently split into multiple files: supplementalData.xml, supplementalMetadata.xml, characters.xml, likelySubtags.xml, ordinals.xml, plurals.xml, telephoneCodeData.xml, genderList.xml, plus transforms (see _Part 2 [Transforms](tr35-general.md#Transforms)_ and _Part 2 [Transform Rule Syntax](tr35-general.md#Transform_Rules_Syntax)_). The split is just for convenience: logically, they are treated as though they were a single file. Future versions of CLDR may split the data in a different fashion. Do not depend on any specific XML filename or path for supplemental data. 117 118Note that [Chapter 10](#Metadata_Elements) presents information about metadata that is maintained on a per-locale basis. It is included in this section because it is not intended to be used as part of the locale itself. 119 120## <a name="Territory_Data" href="#Territory_Data">Territory Data</a> 121 122### <a name="Supplemental_Territory_Containment" href="#Supplemental_Territory_Containment">Supplemental Territory Containment</a> 123 124```xml 125<!ELEMENT territoryContainment ( group* ) > 126<!ELEMENT group EMPTY > 127<!ATTLIST group type NMTOKEN #REQUIRED > 128<!ATTLIST group contains NMTOKENS #IMPLIED > 129<!ATTLIST group grouping ( true | false ) #IMPLIED > 130<!ATTLIST group status ( deprecated, grouping ) #IMPLIED > 131``` 132 133The following data provides information that shows groupings of countries (regions). The data is based on the [[UNM49](tr35.md#UNM49)]. There is one special code, `QO` , which is used for outlying areas of Oceania that are typically uninhabited. The territory containment forms a tree with the following levels: 134 135+ World 136 + Continent 137 + Subcontinent 138 + Country 139 140Excluding groupings, in this tree: 141 142* All non-overlapping regions form a strict tree rooted at World. 143* All leaf-nodes (country) are always at depth 4. Some of these “country” regions are actually parts of other countries, such as Hong Kong (part of China). Such relationships are not part of the containment data. 144 145For a chart showing the relationships (plus the included timezones), see the [Territory Containment Chart](https://unicode-org.github.io/cldr-staging/charts/38/supplemental/territory_containment_un_m_49.html). The XML structure has the following form. 146 147```xml 148<territoryContainment> 149 150 <group type="001" contains="002 009 019 142 150"/> <!--World --> 151 <group type="011" contains="BF BJ CI CV GH GM GN GW LR ML MR NE NG SH SL SN TG"/> <!--Western Africa --> 152 <group type="013" contains="BZ CR GT HN MX NI PA SV"/> <!--Central America --> 153 <group type="014" contains="BI DJ ER ET KE KM MG MU MW MZ RE RW SC SO TZ UG YT ZM ZW"/> <!--Eastern Africa --> 154 <group type="142" contains="030 035 062 145"/> <!--Asia --> 155 <group type="145" contains="AE AM AZ BH CY GE IL IQ JO KW LB OM PS QA SA SY TR YE"/> <!--Western Asia --> 156 <group type="015" contains="DZ EG EH LY MA SD TN"/> <!--Northern Africa --> 157... 158``` 159 160There are groupings that don't follow this regular structure, such as: 161 162```xml 163<group type="003" contains="013 021 029" grouping="true"/> <!--North America --> 164``` 165 166These are marked with the attribute `grouping="true"`. 167 168When groupings have been deprecated but kept around for backwards compatibility, they are marked with the attribute `status="deprecated"`, like this: 169 170```xml 171<group type="029" contains="AN" status="deprecated"/> <!--Caribbean --> 172``` 173 174When the containment relationship itself is a grouping, it is marked with the attribute `status="grouping"`, like this: 175 176```xml 177<group type="150" contains="EU" status="grouping"/> <!--Europe --> 178``` 179 180That is, the type value isn’t a grouping, but if you filter out groupings you can drop this containment. In the example above, EU is a grouping, and contained in 150. 181 182### <a name="Subdivision_Containment" href="#Subdivision_Containment">Subdivision Containment</a> 183 184```xml 185<!ELEMENT subdivisionContainment ( subgroup* ) > 186 187<!ELEMENT subgroup EMPTY > 188<!ATTLIST subgroup type NMTOKEN #REQUIRED > 189<!ATTLIST subgroup contains NMTOKENS #IMPLIED > 190``` 191 192The subdivision containment data is similar to the territory containment. It is based on ISO 3166-2 data, but may diverge from it in the future. 193 194```xml 195<subgroup type="BD" contains="bda bdb bdc bdd bde bdf bdg bdh" /> 196<subgroup type="bda" contains="bd02 bd06 bd07 bd25 bd50 bd51" /> 197``` 198 199The `type` is a [`unicode_region_subtag`](tr35.md#unicode_region_subtag) (territory) identifier for the top level of containment, or a [`unicode_subdivision_id`](tr35.md#unicode_subdivision_id) for lower levels of containment when there are multiple levels. The `contains` value is a space-delimited list of one or more [`unicode_subdivision_id`](tr35.md#unicode_subdivision_id) values. In the example above, subdivision bda contains other subdivisions bd02, bd06, bd07, bd25, bd50, bd51. 200 201Note: Formerly (in CLDR 28 through 30): 202 203* The `type` attribute could only contain a `unicode_region_subtag`; 204* The `contains` attribute contained `unicode_subdivision_suffix` values; these are not unique across multiple territories, so... 205* For lower containment levels, a now-deprecated subtype `attribute` was used to specify the parent `unicode_subdivision_suffix`. 206 207\* The type attribute contained only a `unicode_region_subtag` `unicode_subdivision_suffix` values were used in the `contains` attribute; these are not unique across multiple territories, so for lower levels a now-deprecated 208 209### <a name="Supplemental_Territory_Information" href="#Supplemental_Territory_Information">Supplemental Territory Information</a> 210 211```xml 212<!ELEMENT territory ( languagePopulation* ) > 213<!ATTLIST territory type NMTOKEN #REQUIRED > 214<!ATTLIST territory gdp NMTOKEN #REQUIRED > 215<!ATTLIST territory literacyPercent NMTOKEN #REQUIRED > 216<!ATTLIST territory population NMTOKEN #REQUIRED > 217 218<!ELEMENT languagePopulation EMPTY > 219<!ATTLIST languagePopulation type NMTOKEN #REQUIRED > 220<!ATTLIST languagePopulation literacyPercent NMTOKEN #IMPLIED > 221<!ATTLIST languagePopulation writingPercent NMTOKEN #IMPLIED > 222<!ATTLIST languagePopulation populationPercent NMTOKEN #REQUIRED > 223<!ATTLIST languagePopulation officialStatus (de_facto_official | official | official_regional | official_minority) #IMPLIED > 224``` 225 226This data provides testing information for language and territory populations. The main goal is to provide approximate figures for the literate, functional population for each language in each territory: that is, the population that is able to read and write each language, and is comfortable enough to use it with computers. For a chart of this data, see [Territory-Language Information](https://unicode-org.github.io/cldr-staging/charts/38/supplemental/territory_language_information.html). 227 228_Example_ 229 230```xml 231<territory type="AO" gdp="175500000000" literacyPercent="70.4" population="19088100"> <!--Angola--> 232 <languagePopulation type="pt" populationPercent="67" officialStatus="official"/> <!--Portuguese--> 233 <languagePopulation type="umb" populationPercent="29"/> <!--Umbundu--> 234 <languagePopulation type="kmb" writingPercent="10" populationPercent="25" references="R1034"/> <!--Kimbundu--> 235 <languagePopulation type="ln" populationPercent="0.67" references="R1010"/> <!--Lingala--> 236</territory> 237``` 238 239Note that reliable information is difficult to obtain; the information in CLDR is an estimate culled from different sources, including the World Bank, CIA Factbook, and others. The GDP and country literacy figures are taken from the World Bank where available, otherwise supplemented by FactBook data and other sources. The GDP figures are “PPP (constant 2000 international $)”. Much of the per-language data is taken from the Ethnologue, but is supplemented and processed using many other sources, including per-country census data. (The focus of the Ethnologue is native speakers, which includes people who are not literate, and excludes people who are functional second-language users.) Some references are marked in the XML files, with attributes such as `references="R1010"` . 240 241The percentages may add up to more than 100% due to multilingual populations, or may be less than 100% due to illiteracy or because the data has not yet been gathered or processed. Languages with smaller populations might not be included. 242 243The following describes the meaning of some of these terms—as used in CLDR—in more detail. 244 245<a name="literacy_percent" href="#literacy_percent">literacy percent for the territory</a> — an estimate of the percentage of the country’s population that is functionally literate. 246 247<a name="language_population_percent" href="#language_population_percent">language population percent</a> — an estimate of the number of people who are functional in that language in that country, including both first and second language speakers. The level of fluency is that necessary to use a UI on a computer, smartphone, or similar devices, rather than complete fluency. 248 249<a name="literacy_percent_for_langPop" href="#literacy_percent_for_langPop">literacy percent for language population</a> — Within the set of people who are functional in the corresponding language (as specified by [language population percent](#language_population_percent)), this is an estimate of the percentage of those people who are functionally literate in that language, that is, who are _capable_ of reading or writing in that language, even if they do not regularly use it for reading or writing. If not specified, this defaults to the [literacy percent for the territory](#literacy_percent). 250 251<a name="writing_percent" href="#writing_percent">writing percent</a> — Within the set of people who are functional in the corresponding language (as specified by [language population percent](#language_population_percent)), this is an estimate of the percentage of those people who regularly read or write a significant amount in that language. Ideally, the regularity would be measured as “7-day actives”. If it is known that the language is not widely or commonly written, but there are no solid figures, the value is typically given 1%-5%. 252 253For a language such as Swiss German, which is typically not written, even though nearly the whole native Germanophone population _could_ write in Swiss German, the [literacy percent for language population](#literacy_percent_for_langPop) is high, but the [writing percent](#writing_percent) is low. 254 255<a name="official_language" href="#official_language">official language</a> — as used in CLDR, a language that can generally be used in all communications with a central government. That is, people can expect that essentially all communication from the government is available in that language (ballots, information pamphlets, legal documents, …) and that they can use that language in any communication to the central government (petitions, forms, filing lawsuits, …). 256 257Official languages for a country in this sense are not necessarily the same as those with official legal status in the country. For example, Irish is declared to be an official language in Ireland, but English has no such formal status in the United States. Languages such as the latter are called _de facto_ official languages. As another example, German has legal status in Italy, but cannot be used in all communications with the central government, and is thus not an official language _of Italy_ for CLDR purposes. It is, however, an _official regional language_. Other languages are declared to be official, but can’t actually be used for all communication with any major governmental entity in the country. There is no intention to mark such nominally official languages as “official” in the CLDR data. 258 259<a name="official_regional_language" href="#official_regional_language">official regional language</a> — a language that is official (_de jure_ or _de facto_) in a major region within a country, but does not qualify as an official language of the country as a whole. For example, it can be used in an official petition to a provincial government, but not the central government. The term “major” is meant to distinguish from smaller-scale usage, such as for a town or village. 260 261### <a name="Territory_Based_Preferences" href="#Territory_Based_Preferences">Territory-Based Preferences</a> 262 263The default preference for several locale items is based solely on a [unicode_region_subtag](tr35.md#unicode_region_subtag), which may either be specified as part of a [unicode_language_id](tr35.md#unicode_language_id), inferred from other locale ID elements using the [Likely Subtags](tr35.md#Likely_Subtags) mechanism, or provided explicitly using an “rg” [Region Override](tr35.md#RegionOverride) locale key. For more information on this process see [Locale Inheritance and Matching](tr35.md#Locale_Inheritance). The specific items that are handled in this way are: 264 265* Default calendar (see [Calendar Preference Data](tr35-dates.md#Calendar_Preference_Data)) 266* Default week conventions (first day of week and weekend days; see [Week Data](tr35-dates.md#Week_Data)) 267* Default hour cycle (see [Time Data](tr35-dates.md#Time_Data)) 268* Default currency (see [Supplemental Currency Data](tr35-numbers.md#Supplemental_Currency_Data)) 269* Default measurement system and paper size (see [Measurement System Data](tr35-general.md#Measurement_System_Data)) 270* Default units for specific usage (see [Preferred Units for Specific Usages](#Preferred_Units_For_Usage), below) 271 272The mu, ms, and rg keys also interact with the base locale and the unit preferences. For more information, see _[Unit Preferences](#Unit_Preferences)._ 273 274#### <a name="Preferred_Units_For_Usage" href="#Preferred_Units_For_Usage">Preferred Units for Specific Usages</a> 275 276The determination of preferred units depends on the locale identifer: the keys mu, ms, rg, the base locale (language, script, region) and the user preferences. 277_For information about preferred units and unit conversion, see [Unit Conversion](#Unit_Conversion) and [Unit Preferences](#Unit_Preferences)._ 278 279### <a name="rgScope" href="#rgScope">`<rgScope>`: Scope of the “rg” Locale Key</a> 280 281The supplemental `<rgScope>` element specifies the data paths for which the region used for data lookup is determined by the value of any “rg” key present in the locale identifier (see [Region Override](tr35.md#RegionOverride) and [Region Priority Inheritance](tr35.md#Region_Priority_Inheritance)). If no “rg” key is present, the region used for lookup is determined as usual: from the unicode_region_subtag if present, else inferred from the unicode_language_subtag. The DTD structure is as follows: 282 283```xml 284<!ELEMENT rgScope ( rgPath* ) > 285 286<!ELEMENT rgPath EMPTY > 287<!ATTLIST rgPath path CDATA #REQUIRED > 288``` 289 290The `<rgScope>` element contains a list of `<rgPath>` elements, each of which specifies a datapath for which any “rg” key determines the region for lookup. For example: 291 292```xml 293<rgScope> 294 <rgPath path="//supplementalData/currencyData/fractions/info[@iso4217='#'][@digits='*'][@rounding='*'][@cashDigits='*'][@cashRounding='*']" draft="provisional" /> 295 <rgPath path="//supplementalData/currencyData/fractions/info[@iso4217='#'][@digits='*'][@rounding='*'][@cashRounding='*']" draft="provisional" /> 296 <rgPath path="//supplementalData/currencyData/fractions/info[@iso4217='#'][@digits='*'][@rounding='*']" draft="provisional" /> 297 <rgPath path="//supplementalData/calendarPreferenceData/calendarPreference[@territories='#'][@ordering='*']" draft="provisional" /> 298 ... 299 <rgPath path="//supplementalData/unitPreferenceData/unitPreferences[@category='*'][@usage='*'][@scope='*']/unitPreference[@regions='#'][@alt='*']" draft="provisional" /> 300 <rgPath path="//supplementalData/unitPreferenceData/unitPreferences[@category='*'][@usage='*'][@scope='*']/unitPreference[@regions='#']" draft="provisional" /> 301 <rgPath path="//supplementalData/unitPreferenceData/unitPreferences[@category='*'][@usage='*']/unitPreference[@regions='#'][@alt='*']" draft="provisional" /> 302 <rgPath path="//supplementalData/unitPreferenceData/unitPreferences[@category='*'][@usage='*']/unitPreference[@regions='#']" draft="provisional" /> 303</rgScope> 304``` 305 306The exact format of the path is provisional in CLDR 29, but as currently shown: 307 308* An attribute value of `'*'` indicates that the path applies regardless of the value of the attribute. 309* Each path must have exactly one attribute whose value is marked here as `'#'`; in actual data items with this path, the corresponding value is a list of region codes. It is the region codes in this list that are compared with the region specified by the “rg” key to determine which data item to use for this path. 310 311## <a name="Supplemental_Language_Data" href="#Supplemental_Language_Data">Supplemental Language Data</a> 312 313```xml 314<!ELEMENT languageData ( language* ) > 315<!ELEMENT language EMPTY > 316<!ATTLIST language type NMTOKEN #REQUIRED > 317<!ATTLIST language scripts NMTOKENS #IMPLIED > 318<!ATTLIST language territories NMTOKENS #IMPLIED > 319<!ATTLIST language variants NMTOKENS #IMPLIED > 320<!ATTLIST language alt NMTOKENS #IMPLIED > 321``` 322 323The language data is used for consistency checking and testing. It provides a list of which languages are used with which scripts and in which countries. To a large extent, however, the territory list has been superseded by the data in _[Supplemental Territory Information](#Supplemental_Territory_Information)_ . 324 325```xml 326<languageData> 327 <language type="af" scripts="Latn" territories="ZA" /> 328 <language type="am" scripts="Ethi" territories="ET" /> 329 <language type="ar" scripts="Arab" territories="AE BH DZ EG IN IQ JO KW LB LY MA OM PS QA SA SD SY TN YE" /> 330 ... 331``` 332 333If the language is not a modern language, or the script is not a modern script, or the language not a major language of the territory, then the `alt` attribute is set to secondary. 334 335```xml 336 <language type="fr" scripts="Latn" territories="IT US" alt="secondary" /> 337 ... 338``` 339 340## <a name="Supplemental_Language_Grouping" href="#Supplemental_Language_Grouping">Supplemental Language Grouping</a> 341 342```xml 343<!ELEMENT languageGroups ( languageGroup* ) > 344<!ELEMENT languageGroup ( #PCDATA ) > 345<!ATTLIST languageGroup parent NMTOKEN #REQUIRED > 346``` 347 348The language groups supply language containment. For example, the following indicates that aav is the Unicode language code for a language group that contains caq, crv, etc. 349 350```xml 351<languageGroup parent="fiu">chm et fi fit fkv hu izh kca koi krl kv liv mdf mns mrj myv smi udm vep vot vro</languageGroup> 352``` 353 354The vast majority of the languageGroup data is extracted from Wikidata, but may be overridden in some cases. The Wikidata information is more fine-grained, but makes use of language groups that don't have ISO or Unicode language codes. Those language groups are omitted from the data. For example, Wikidata has the following child-parent chain: only the first and last elements are present in the language groups. 355 356| Name | Wikidata Code | Language Code | 357| ------------------------- | ------------------------------------------------ | ------------- | 358| Finnish | [Q1412](https://www.wikidata.org/wiki/Q1412) | fi | 359| Finnic languages | [Q33328](https://www.wikidata.org/wiki/Q33328) | 360| Finno-Samic languages | [Q163652](https://www.wikidata.org/wiki/Q163652) | 361| Finno-Volgaic languages | [Q161236](https://www.wikidata.org/wiki/Q161236) | 362| Finno-Permic languages | [Q161240](https://www.wikidata.org/wiki/Q161240) | 363| Finno-Ugric languages | [Q79890](https://www.wikidata.org/wiki/Q79890) | fiu | 364 365## <a name="Supplemental_Code_Mapping" href="#Supplemental_Code_Mapping">Supplemental Code Mapping</a> 366 367```xml 368<!ELEMENT codeMappings (languageCodes*, territoryCodes*, currencyCodes*) > 369 370<!ELEMENT languageCodes EMPTY > 371<!ATTLIST languageCodes type NMTOKEN #REQUIRED> 372<!ATTLIST languageCodes alpha3 NMTOKEN #REQUIRED> 373 374<!ELEMENT territoryCodes EMPTY > 375<!ATTLIST territoryCodes type NMTOKEN #REQUIRED> 376<!ATTLIST territoryCodes numeric NMTOKEN #REQUIRED> 377<!ATTLIST territoryCodes alpha3 NMTOKEN #REQUIRED> 378<!ATTLIST territoryCodes fips10 NMTOKEN #IMPLIED> 379<!ATTLIST territoryCodes internet NMTOKENS #IMPLIED> [deprecated] 380 381<!ELEMENT currencyCodes EMPTY > 382<!ATTLIST currencyCodes type NMTOKEN #REQUIRED> 383<!ATTLIST currencyCodes numeric NMTOKEN #REQUIRED> 384``` 385 386The code mapping information provides mappings between the subtags used in the CLDR locale IDs (from BCP 47) and other coding systems or related information. The language codes are only provided for those codes that have two letters in BCP 47 to their ISO three-letter equivalents. The territory codes provide mappings to numeric (UN M.49 [[UNM49](tr35.md#UNM49)] codes, equivalent to ISO numeric codes), ISO three-letter codes, FIPS 10 codes, and the internet top-level domain codes. 387 388The alphabetic codes are only provided where different from the type. For example: 389 390```xml 391<territoryCodes type="AA" numeric="958" alpha3="AAA" /> 392<territoryCodes type="AD" numeric="020" alpha3="AND" fips10="AN" /> 393<territoryCodes type="AE" numeric="784" alpha3="ARE" /> 394... 395<territoryCodes type="GB" numeric="826" alpha3="GBR" fips10="UK" /> 396... 397<territoryCodes type="QU" numeric="967" alpha3="QUU" internet="EU" /> 398... 399<territoryCodes type="XK" numeric="983" alpha3="XKK" /> 400... 401``` 402 403Where there is no corresponding code, sometimes private use codes are used, such as the numeric code for XK. 404 405The currencyCodes are mappings from three letter currency codes to numeric values (ISO 4217, see [Current currency & funds code list](https://www.six-group.com/en/products-services/financial-information/data-standards.html#scrollTo=maintenance-agency)). The mapping currently covers only current codes and does not include historic currencies. For example: 406 407```xml 408<currencyCodes type="AED" numeric="784" /> 409<currencyCodes type="AFN" numeric="971" /> 410... 411<currencyCodes type="EUR" numeric="978" /> 412... 413<currencyCodes type="ZAR" numeric="710" /> 414<currencyCodes type="ZMW" numeric="967" /> 415``` 416 417## ~~<a name="Telephone_Code_Data" href="#Telephone_Code_Data">Telephone Code Data</a>~~ (Deprecated) 418 419Deprecated in CLDR v34, and data removed. 420The data and structure for phone numbers changes quite often, so the recommended alternative is the open-source library [libphonenumber](https://github.com/google/libphonenumber#what-is-it). 421 422```xml 423<!ELEMENT telephoneCodeData ( codesByTerritory* ) > 424 425<!ELEMENT codesByTerritory ( telephoneCountryCode+ ) > 426<!ATTLIST codesByTerritory territory NMTOKEN #REQUIRED > 427 428<!ELEMENT telephoneCountryCode EMPTY > 429<!ATTLIST telephoneCountryCode code NMTOKEN #REQUIRED > 430<!ATTLIST telephoneCountryCode from NMTOKEN #IMPLIED > 431<!ATTLIST telephoneCountryCode to NMTOKEN #IMPLIED > 432``` 433 434This data specifies the mapping between ITU telephone country codes [[ITUE164](tr35.md#ITUE164)] and CLDR-style territory codes (ISO 3166 2-letter codes or non-corresponding UN M.49 [[UNM49](tr35.md#UNM49)] 3-digit codes). There are several things to note: 435 436* A given telephone country code may map to multiple CLDR territory codes; +1 (North America Numbering Plan) covers the US and Canada, as well as many islands in the Caribbean and some in the Pacific 437* Some telephone country codes are for global services (for example, some satellite services), and thus correspond to territory code 001. 438* The mappings change over time (territories move from one telephone code to another). These changes are usually planned several years in advance, and there may be a period during which either telephone code can be used to reach the territory. While the CLDR telephone code data is not intended to include past changes, it is intended to incorporate known information on planned future changes, using `from` and `to` date attributes to indicate when mappings are valid. 439 440A subset of the telephone code data might look like the following (showing a past mapping change to illustrate the from and to attributes): 441 442```xml 443<codesByTerritory territory="001"> 444 <telephoneCountryCode code="800"/> <!-- International Freephone Service --> 445 <telephoneCountryCode code="808"/> <!-- International Shared Cost Services (ISCS) --> 446 <telephoneCountryCode code="870"/> <!-- Inmarsat Single Number Access Service (SNAC) --> 447</codesByTerritory> 448<codesByTerritory territory="AS"> <!-- American Samoa --> 449 <telephoneCountryCode code="1" from="2004-10-02"/> <!-- +1 684 in North America Numbering Plan --> 450 <telephoneCountryCode code="684" to="2005-04-02"/> <!-- +684 now a spare code --> 451</codesByTerritory> 452<codesByTerritory territory="CA"> 453 <telephoneCountryCode code="1"/> <!-- North America Numbering Plan --> 454</codesByTerritory> 455``` 456 457## ~~<a name="Postal_Code_Validation" href="#Postal_Code_Validation">Postal Code Validation (Deprecated)</a>~~ 458 459Deprecated in v27. Please see other services that are kept up to date, such as <https://github.com/google/libaddressinput> 460 461```xml 462<!ELEMENT postalCodeData (postCodeRegex*) > 463<!ELEMENT postCodeRegex (#PCDATA) > 464<!ATTLIST postCodeRegex territoryId NMTOKEN #REQUIRED > 465``` 466 467The Postal Code regex information can be used to validate postal codes used in different countries. In some cases, the regex is quite simple, such as for Germany: 468 469```xml 470<postCodeRegex territoryId="DE" >\d{5}</postCodeRegex> 471``` 472 473The US code is slightly more complicated, since there is an optional portion: 474 475```xml 476<postCodeRegex territoryId="US" >\d{5}([ \-]\d{4})?</postCodeRegex> 477``` 478 479The most complicated currently is the UK. 480 481## <a name="Supplemental_Character_Fallback_Data" href="#Supplemental_Character_Fallback_Data">Supplemental Character Fallback Data</a> 482 483```xml 484<!ELEMENT characters ( character-fallback*) > 485 486<!ELEMENT character-fallback ( character* ) > 487<!ELEMENT character (substitute*) > 488<!ATTLIST character value CDATA #REQUIRED > 489 490<!ELEMENT substitute (#PCDATA) > 491``` 492 493The `characters` element provides a way for non-Unicode systems, or systems that only support a subset of Unicode characters, to transform CLDR data. It gives a list of characters with alternative values that can be used if the main value is not available. For example: 494 495```xml 496<characters> 497 <character-fallback> 498 <character value="ß"> 499 <substitute>ss</substitute> 500 </character> 501 <character value="Ø"> 502 <substitute>Ö</substitute> 503 <substitute>O</substitute> 504 </character> 505 <character value="₧"> 506 <substitute>Pts</substitute> 507 </character> 508 <character value="₣"> 509 <substitute>Fr.</substitute> 510 </character> 511 </character-fallback> 512</characters> 513``` 514 515The ordering of the `substitute` elements indicates the preference among them. 516 517That is, this data provides recommended fallbacks for use when a charset or supported repertoire does not contain a desired character. There is more than one possible fallback: the recommended usage is that when a character _value_ is not in the desired repertoire the following process is used, whereby the first value that is wholly in the desired repertoire is used. 518 519* `toNFC`(_value_) 520* other canonically equivalent sequences, if there are any 521* the explicit _substitutes_ value (in order) 522* `toNFKC`(_value_) 523 524## <a name="Coverage_Levels" href="#Coverage_Levels">Coverage Levels</a> 525 526The following describes the structure used to set coverage levels used for CLDR. 527That structure is used in CLDR tooling, and can also be used by consumers of CLDR data, such as described in [Data Size Reduction](tr35.md#Data_Size). 528 529The following lists the coverage levels. The qualifications for each level may change between releases of CLDR, and more detailed information for each level is on [Coverage Levels](https://cldr.unicode.org/index/cldr-spec/coverage-levels). Each level adds to what is in the lower level, so Basic includes all of Core, Moderate all of Basic, and so on. 530 531| Code | Level | Description | 532| ----: | ------------- | -------------- | 533| 0 | undetermined | Does not meet any of the following levels. | 534| 10 | core | Core Locale — Has minimal data about the language and writing system that is required before other information can be added using the CLDR survey tool. | 535| 40 | basic | Selectable Locale — Minimal locale data necessary for a "selectable" locale in a platform UI. Very basic number and datetime formatting, etc. | 536| 60 | moderate | Document Content Locale — Minimal locale data for applications such as spreadsheets and word processors to support general document content internationalization: formatting number, datetime, currencies, sorting, plural handling, and so on. | 537| 80 | modern | UI Locale — Contains all fields in normal modern use, including all CLDR locale names, country names, timezone names, currencies in use, and so on. | 538| 100 | comprehensive | Above modern level; typically more data than is needed in most implementations. | 539 540The Basic through Modern levels are based on the definitions and specifications listed below. 541 542```xml 543<!ELEMENT coverageLevels ( approvalRequirements, coverageVariable*, coverageLevel* ) > 544<!ELEMENT coverageLevel EMPTY > 545<!ATTLIST coverageLevel inLanguage CDATA #IMPLIED > 546<!ATTLIST coverageLevel inScript CDATA #IMPLIED > 547<!ATTLIST coverageLevel inTerritory CDATA #IMPLIED > 548<!ATTLIST coverageLevel value CDATA #REQUIRED > 549<!ATTLIST coverageLevel match CDATA #REQUIRED > 550``` 551 552For example, here is an example coverageLevel line. 553 554```xml 555<coverageLevel 556 value="30" 557 inLanguage="(de|fi)" 558 match="localeDisplayNames/types/type[@type='phonebook'][@key='collation']"/> 559``` 560 561The `coverageLevel` elements are read in order, and the first match results in a coverage level value. The element matches based on the `inLanguage`, `inScript`, `inTerritory`, and `match` attribute values, which are regular expressions. For example, in the above example, a match occurs if the language is de or fi, and if the path is a locale display name for `collation=phonebook`. 562 563The `match` attribute value logically has `//ldml/` prefixed before it is applied. In addition, the `[@` is automatically quoted. Otherwise standard Perl/Java style regular expression syntax is used. 564 565```xml 566<!ELEMENT coverageVariable EMPTY > 567<!ATTLIST coverageVariable key CDATA #REQUIRED > 568<!ATTLIST coverageVariable value CDATA #REQUIRED > 569``` 570 571The `coverageVariable` element allows us to create variables for certain regular expressions that are used frequently in the coverageLevel definitions above. Each coverage variable must contain a `key` / `value` pair of attributes, which can then be used to be substituted into a coverageLevel definition above. 572 573For example, here is an example coverageLevel line using coverageVariable substitution. 574 575```xml 576<coverageVariable key="%dayTypes" value="(sun|mon|tue|wed|thu|fri|sat)"> 577<coverageVariable key="%wideAbbr" value="(wide|abbreviated)"> 578<coverageLevel value="20" match="dates/calendars/calendar[@type='gregorian']/days/dayContext[@type='format']/dayWidth[@type='%wideAbbr']/day[@type='%dayTypes']"/> 579``` 580 581In this example, the coverge variables %dayTypes and %wideAbbr are used to substitute their respective values into the match expression. This allows us to reuse the same variable for other coverageLevel matches that use the same regular expression fragment. 582 583```xml 584<!ELEMENT approvalRequirements ( approvalRequirement* ) > 585<!ELEMENT approvalRequirement EMPTY > 586<!ATTLIST approvalRequirement votes CDATA #REQUIRED > 587<!ATTLIST approvalRequirement locales CDATA #REQUIRED > 588<!ATTLIST approvalRequirement paths CDATA #REQUIRED > 589``` 590 591The approvalRequirements allows to specify the number of survey tool votes required for approval, either based on locale, or path, or both. Certain locales require a higher voting threshold (usually 8 votes instead of 4), in order to promote greater stability in the data. Furthermore, certain fields that are very high visibility fields, such as number formats, require a CLDR TC committee member's vote for approval. 592 593`votes=` can be a numeric value, or it can be of the form `=vetter` where `vetter` is one of the `VoteResolver.Level` enumerated values. 594It can also be `=LOWER_BAR` (8) or `=HIGH_BAR` (same as `=tc`) referring to the `VoteResolver` constants of the same names. 595 596Here is an example of the approvalRequirements section. 597 598```xml 599<approvalRequirements> 600 <!-- "high bar" items --> 601 <approvalRequirement votes="=HIGH_BAR" locales="*" paths="//ldml/numbers/symbols[^/]++/(decimal|group)"/> 602 <!-- established locales - https://cldr.unicode.org/index/process#h.rm00w9v03ia8 --> 603 <approvalRequirement votes="=LOWER_BAR" locales="ar ca cs da de el es fi fr he hi hr hu it ja ko nb nl pl pt pt_PT ro ru sk sl sr sv th tr uk vi zh zh_Hant" paths=""/> 604 <!-- all other items --> 605 <approvalRequirement votes="=vetter" locales="*" paths=""/> 606</approvalRequirements> 607``` 608 609This section specifies that a TC vote (20 votes) is required for decimal and grouping separators. Furthermore it specifies that any field in the established locales list (i.e. ar, ca, cs, etc.) requires 8 votes, and that all other locales require 4 votes only. 610 611For more information on the CLDR Voting process, see [https://cldr.unicode.org/index/process](https://cldr.unicode.org/index/process) 612 613### <a name="Coverage_Level_Definitions" href="#Coverage_Level_Definitions">Definitions</a> 614This is a snapshot of the contents of certain variables. The actual definitions in the coverageLevels.xml file may vary from these descriptions. 615 616* _Target-Language_ is the language under consideration. 617* _Target-Territories_ is the list of territories found by looking up _Target-Language_ in the `<languageData>` elements in [Supplemental Language Data](tr35-info.md#Supplemental_Language_Data). 618* _Language-List_ is _Target-Language_, plus 619 * **moderate:** Chinese, English, French, German, Italian, Japanese, Portuguese, Russian, Spanish, Unknown; Arabic, Hindi, Korean, Indonesian, Dutch, Bengali, Turkish, Thai, Polish (de, en, es, fr, it, ja, pt, ru, zh, und, ar, hi, ko, in, nl, bn, tr, th, pl). If an EU language, add the remaining official EU languages. 620 * **modern:** all languages that are official or major commercial languages of modern territories 621* _Target-Scripts_ is the list of scripts in which _Target-Language_ can be customarily written (found by looking up _Target-Language_ in the `<languageData>` elements in [Supplemental Language Data](tr35-info.md#Supplemental_Language_Data))_,_ plus Unknown (Zzzz)_._ 622* _Script-List_ is the _Target-Scripts_ plus the major scripts used for multiple languages 623 * Latin, Simplified Chinese, Traditional Chinese, Cyrillic, Arabic (Latn, Hans, Hant, Cyrl, Arab) 624* _Territory-List_ is the list of territories formed by taking the _Target-Territories_ and adding: 625 * **moderate:** Brazil, China, France, Germany, India, Italy, Japan, Russia, United Kingdom, United States, Unknown; Spain, Canada, Korea, Mexico, Australia, Netherlands, Switzerland, Belgium, Sweden, Turkey, Austria, Indonesia, Saudi Arabia, Norway, Denmark, Poland, South Africa, Greece, Finland, Ireland, Portugal, Thailand, Hong Kong SAR China, Taiwan (BR, CN, DE, GB, FR, IN, IT, JP, RU, US, ZZ, ES, BE, SE, TR, AT, ID, SA, NO, DK, PL, ZA, GR, FI, IE, PT, TH, HK, TW). If an EU language, add the remaining member EU countries. 626 * **modern:** all current ISO 3166 territories, plus the UN M.49 [[UNM49](tr35.md#UNM49)] regions in [Supplemental Territory Containment](tr35-info.md#Supplemental_Territory_Containment). 627* _Currency-List_ is the list of current official currencies used in any of the territories in _Territory-List_, found by looking at the `region` elements in [Supplemental Territory Containment](tr35-info.md#Supplemental_Territory_Containment), plus Unknown (XXX). 628* _Calendar-List_ is the set of calendars in customary use in any of _Target-Territories_, plus Gregorian. 629* _Number-System-List_ is the set of number systems in customary use in the language. 630 631### <a name="Coverage_Level_Data_Requirements" href="#Coverage_Level_Data_Requirements">Data Requirements</a> 632 633The required data to qualify for each level based on these definitions is then the following. 634 6351. localeDisplayNames 636 1. _languages:_ localized names for all languages in _Language-List._ 637 2. _scripts:_ localized names for all scripts in _Script-List_. 638 3. _territories:_ localized names for all territories in _Territory-List_. 639 4. _variants, keys, types:_ localized names for any in use in _Target-Territories_; for example, a translation for PHONEBOOK in a German locale. 640 6412. dates: all of the following for each calendar in _Calendar-List_. 642 1. calendars: localized names 643 2. month names, day names, era names, and quarter names 644 * context=format and width=narrow, wide, & abbreviated 645 * plus context=standAlone and width=narrow, wide, & abbreviated, _if the grammatical forms of these are different than for context=format._ 646 3. week: minDays, firstDay, weekendStart, weekendEnd 647 * if some of these vary in territories in _Territory-List_, include territory locales for those that do. 648 4. am, pm, eraNames, eraAbbr 649 5. dateFormat, timeFormat: full, long, medium, short 650 6. intervalFormatFallback 651 6523. numbers: symbols, decimalFormats, scientificFormats, percentFormats, currencyFormats for each number system in _Number-System-List_. 6534. currencies: displayNames and symbol for all currencies in _Currency-List_, for all plural forms 6545. transforms: (moderate and above) transliteration between Latin and each other script in _Target-Scripts._ 655 656### <a name="Coverage_Level_Default_Values" href="#Coverage_Level_Default_Values">Default Values</a> 657 658Items should _only_ be included if they are not the same as the default, which is: 659 660* what is in root, if there is something defined there. 661* for timezone IDs: the name computed according to _[Appendix J: Time Zone Display Names](tr35.md#Time_Zone_Fallback)_ 662* for collation sequence, the UCA DUCET (Default Unicode Collation Element Table), as modified by CLDR. 663 * however, in that case the locale must be added to the validSubLocale list in [collation/root.xml](https://github.com/unicode-org/cldr/blob/main/common/collation/root.xml). 664* for currency symbol, language, territory, script names, variants, keys, types, the internal code identifiers, for example, 665 * currencies: EUR, USD, JPY, ... 666 * languages: en, ja, ru, ... 667 * territories: GB, JP, FR, ... 668 * scripts: Latn, Thai, ... 669 * variants: PHONEBOOK, ... 670 671## <a name="Appendix_Supplemental_Metadata" href="#Appendix_Supplemental_Metadata">Supplemental Metadata</a> 672 673Note that this section discusses the `<metadata>` element within the `<supplementalData>` element. For the per-locale metadata used in tests and the Survey Tool, see [10: Locale Metadata Element](#Metadata_Elements). 674 675The supplemental metadata contains information about the CLDR file itself, used to test validity and provide information for locale inheritance. A number of these elements are described in 676 677* Appendix I: [Inheritance and Validity](tr35.md#Inheritance_and_Validity) 678* Appendix K: [Valid Attribute Values](tr35.md#Valid_Attribute_Values) 679* Appendix L: [Canonical Form](tr35.md#Canonical_Form) 680* Appendix M: [Coverage Levels](#Coverage_Levels) 681 682### <a name="Supplemental_Alias_Information" href="#Supplemental_Alias_Information">Supplemental Alias Information</a> 683 684```xml 685<!ELEMENT alias (languageAlias*,scriptAlias*,territoryAlias*,subdivisionAlias*,variantAlias*,zoneAlias*) > 686``` 687 688_The following are common attributes for subelements of `<alias>`:_ 689 690```xml 691<!ELEMENT *Alias EMPTY > 692<!ATTLIST *Alias type NMTOKEN #IMPLIED > 693<!ATTLIST *Alias replacement NMTOKEN #IMPLIED > 694<!ATTLIST *Alias reason ( deprecated | overlong ) #IMPLIED > 695``` 696 697_The `languageAlias` has additional reasons_ 698 699```xml 700<!ATTLIST languageAlias reason ( deprecated | overlong | macrolanguage | legacy | bibliographic ) #IMPLIED > 701``` 702 703This element provides information as to parts of locale IDs that should be substituted when accessing CLDR data. This logical substitution should be done to both the locale id, and to any lookup for display names of languages, territories, and so on. The replacement for the language and territory types is more complicated: see _Part 1: [Core](tr35.md#Contents), [BCP 47 Language Tag Conversion](tr35.md#BCP_47_Language_Tag_Conversion)_ for details. 704 705```xml 706<alias> 707 <languageAlias type="in" replacement="id"> 708 <languageAlias type="sh" replacement="sr"> 709 <languageAlias type="sh_YU" replacement="sr_Latn_YU"> 710 ... 711 <territoryAlias type="BU" replacement="MM"> 712 ... 713</alias> 714``` 715 716Attribute values for the \*Alias values include the following: 717 718###### Table: <a name="Alias_Attribute_Values" href="#Alias_Attribute_Values">Alias Attribute Values</a> 719 720| Attribute | Value | Description | 721| ----------- | ------------- | ----------- | 722| type | NMTOKEN | The code to be replaced | 723| replacement | NMTOKEN | The code(s) to replace it, space-delimited. | 724| reason | deprecated | The code in type is deprecated, such as 'iw' by 'he', or 'CS' by 'RS ME'. | 725| | overlong | The code in type is too long, such as 'eng' by 'en' or 'USA' or '840' by 'US' | 726| | macrolanguage | The code in type is an encompassed language that is replaced by a macrolanguage, such as '[arb'](https://iso639-3.sil.org/code/arb) by 'ar'. | 727| | legacy | The code in type is a legacy code that is replaced by another code for compatibility with established legacy usage, such as 'sh' by 'sr_Latn' | 728| | bibliographic | The code in type is a [bibliographic code](https://www.loc.gov/standards/iso639-2/langhome.html), which is replaced by a terminology code, such as 'alb' by 'sq'. | 729 730### ~~<a name="Supplemental_Deprecated_Information" href="#Supplemental_Deprecated_Information">Supplemental Deprecated Information (Deprecated)</a>~~ 731 732```xml 733<!ELEMENT deprecated ( deprecatedItems* ) > 734<!ATTLIST deprecated draft ( approved | contributed | provisional | unconfirmed | true | false ) #IMPLIED > <!-- true and false are deprecated. --> 735 736<!ELEMENT deprecatedItems EMPTY > 737<!ATTLIST deprecatedItems type ( standard | supplemental | ldml | supplementalData | ldmlBCP47 ) #IMPLIED > <!-- standard | supplemental are deprecated --> 738<!ATTLIST deprecatedItems elements NMTOKENS #IMPLIED > 739<!ATTLIST deprecatedItems attributes NMTOKENS #IMPLIED > 740<!ATTLIST deprecatedItems values CDATA #IMPLIED > 741``` 742 743The `deprecatedItems` element was used to indicate elements, attributes, and attribute values that are deprecated. This means that the items are valid, but that their usage is strongly discouraged. This element and its subelements have been deprecated in favor of [DTD Annotations](tr35.md#DTD_Annotations). 744 745Where particular values are deprecated (such as territory codes like SU for Soviet Union), the names for such codes may be removed from the common/main translated data after some period of time. However, typically supplemental information for deprecated codes is retained, such as containment, likely subtags, older currency codes usage, etc. The English name may also be retained, for debugging purposes. 746 747### <a name="Default_Content" href="#Default_Content">Default Content</a> 748 749```xml 750<!ELEMENT defaultContent EMPTY > 751<!ATTLIST defaultContent locales NMTOKENS #IMPLIED > 752``` 753 754In CLDR, locales without territory information (or where needed, script information) provide data appropriate for what is called the _default content locale_. For example, the _en_ locale contains data appropriate for _en-US_, while the _zh_ locale contains content for _zh-Hans-CN_, and the _zh-Hant_ locale contains content for _zh-Hant-TW_. The default content locales themselves thus inherit all of their contents, and are empty. 755 756The choice of content is typically based on the largest literate population of the possible choices. Thus if an implementation only provides the base language (such as _en_), it will still get a complete and consistent set of data appropriate for a locale which is reasonably likely to be the one meant. Where other information is available, such as independent country information, that information can always be used to pick a different locale (such as _en-CA_ for a website targeted at Canadian users). 757 758If an implementation is to use a different default locale, then the data needs to be _pivoted_; all of the data from the CLDR for the current default locale pushed out to the locales that inherit from it, then the new default content locale's data moved into the base. There are tools in CLDR to perform this operation. 759 760For the relationship between Inheritance, DefaultContent, LikelySubtags, and LocaleMatching, see **_[Inheritance vs Related Information](tr35.md#Inheritance_vs_Related)_**. 761 762## <a name="Metadata_Elements" href="#Metadata_Elements">Locale Metadata Elements</a> 763 764Note: This section refers to the per-locale `<metadata>` element, containing metadata about a particular locale. This is in contrast to the [_Supplemental_ Metadata](#Appendix_Supplemental_Metadata), which is in the supplemental tree and is not specific to a locale. 765 766```xml 767<!ELEMENT metadata ( alias | ( casingData?, special* ) ) > 768<!ELEMENT casingData ( alias | ( casingItem*, special* ) ) > 769<!ELEMENT casingItem ( #PCDATA ) > 770<!ATTLIST casingItem type CDATA #REQUIRED > 771<!ATTLIST casingItem override (true | false) #IMPLIED > 772<!ATTLIST casingItem forceError (true | false) #IMPLIED > 773``` 774 775The `<metadata>` element contains metadata about the locale for use by the Survey Tool or other tools in checking locale data; this data is not intended for export as part of the locale itself. 776 777The `<casingItem>` element specifies the capitalization intended for the majority of the data in a given category with the locale. The purpose is so that warnings can be issued to translators that anything deviating from that capitalization should be carefully reviewed. Its `type` attribute has one of the values used for the `<contextTransformUsage>` element above, with the exception of the special value "all"; its value is one of the following: 778 779* lowercase 780* titlecase 781 782The `<casingItem>` data is generated by a tool based on the data available in CLDR. In cases where the generated casing information is incorrect and needs to be manually edited, the `override` attribute is set to `true` so that the tool will not override the manual edits. When the casing information is known to be both correct and something that should apply to all elements of the specified type in a given locale, the `forceErr` attribute may be set to `true` to force an error instead of a warning for items that do not match the casing information. 783 784## <a name="Version_Information" href="#Version_Information">Version Information</a> 785 786```xml 787<!ELEMENT version EMPTY > 788<!ATTLIST version cldrVersion CDATA #FIXED "27" > 789<!ATTLIST version unicodeVersion CDATA #FIXED "7.0.0" > 790``` 791 792The `cldrVersion` attribute defines the CLDR version for this data, as published on [CLDR Releases/Downloads](https://cldr.unicode.org/index/downloads). 793 794The `unicodeVersion` attribute defines the version of the Unicode standard that is used to interpret data. Specifically, some data elements such as exemplar characters are expressed in terms of UnicodeSets. Since UnicodeSets can be expressed in terms of Unicode properties, their meaning depends on the Unicode version from which property values are derived. 795 796## <a name="Parent_Locales" href="#Parent_Locales">Parent Locales</a> 797 798The parentLocales data is supplemental data, but is described in detail in the [core specification section 4.1.3.](tr35.md#Parent_Locales) 799 800## <a name="Unit_Conversion" href="#Unit_Conversion">Unit Conversion</a> 801 802The unit conversion data ([units.xml](https://github.com/unicode-org/cldr/blob/main/common/supplemental/units.xml)) provides the data for converting all of the cldr unit identifiers to base units, and back. That allows conversion between any two convertible units, such as two units of length. For any two convertible units (such as acre and dunum) the first can be converted to the base unit (square-meter), then that base unit can be converted to the second unit. 803 804### Unit Parsing Data 805 806<!ELEMENT unitIdComponents ( unitIdComponent* ) > 807 808<!ELEMENT unitIdComponent EMPTY > 809<!ATTLIST unitIdComponent type NMTOKEN #REQUIRED > 810<!ATTLIST unitIdComponent values NMTOKENS #REQUIRED > 811 812These elements provide support for parsing unit identifiers, as described in [Unit Elements](tr35-general.md#Unit_Elements). 813Each of the values has tokens with specific functions, identified by the type. 814For example the following values can be suffixes in a simple_unit identifier such as `quart-imperial`. 815 816``` 817<unitIdComponent type="suffix" values="force imperial luminosity mass metric person radius scandinavian troy unit us"/> 818```` 819 820### Unit Prefixes 821```xml 822<!ELEMENT unitPrefixes ( unitPrefix* ) > 823 824<!ELEMENT unitPrefix EMPTY > 825<!ATTLIST unitPrefix type NMTOKEN #REQUIRED > 826<!ATTLIST unitPrefix symbol NMTOKEN #REQUIRED > 827<!ATTLIST unitPrefix power10 NMTOKEN #IMPLIED > 828<!ATTLIST unitPrefix power2 NMTOKEN #IMPLIED > 829``` 830 831This data lists the SI prefixes that can be applied to units (typically limited to prefixable units), 832such as the following: 833```xml 834<unitPrefixes> 835 <unitPrefix type='quecto' symbol='q' power10='-30'/> 836... 837 <unitPrefix type='micro' symbol='μ' power10='-6'/> 838... 839 <unitPrefix type='giga' symbol='G' power10='9'/> 840... 841 <unitPrefix type='quetta' symbol='Q' power10='30'/> 842 <unitPrefix type='kibi' symbol='Ki' power2='10'/> 843... 844 <unitPrefix type='yobi' symbol='Yi' power2='80'/> 845</unitPrefixes> 846``` 847The information includes the SI prefix and symbol, and the power of 10 or power of 2 848(for binary prefixes, intended for use with digital units). 849 850Note that the translated short form of a unit prefix is not the same as the localized symbol. 851The localized symbol may be the same for most Latin-script languages, 852but depending on the customary use in a language they can be in a different script 853or use different letters even in Latin-script languages. They are, however, the same in the root locale. 854 855The newer prefixes (quecto-, ronto-, -ronna, -quetta) are not yet being translated, 856because the appropriate translated versions have not yet been well established across languages. 857 858### Constants 859 860 861```xml 862<!ELEMENT unitConstants ( unitConstant* ) > 863 864<!ELEMENT unitConstant EMPTY > 865<!ATTLIST unitConstant constant NMTOKEN #REQUIRED > 866<!ATTLIST unitConstant value CDATA #REQUIRED > 867<!ATTLIST unitConstant status NMTOKEN #IMPLIED > 868<!ATTLIST unitConstant description CDATA #IMPLIED > 869``` 870 871Many of the elements allow for a common @description attribute, to disambiguate the main attribute value or to explain the choice of other values. For example: 872```xml 873<unitConstant constant="glucose_molar_mass" value="180.1557" 874 description="derivation from the mean atomic weights according to STANDARD ATOMIC WEIGHTS 2019 on https://ciaaw.org/atomic-weights.htm"/> 875``` 876 877The data uses a small set of constants for readability, such as: 878 879```xml 880<unitConstant constant="ft_to_m" value="0.3048" /> 881<unitConstant constant="ft2_to_m2" value="ft_to_m*ft_to_m" /> 882``` 883The order of the elements in the file is significant. 884 885Each constant can have a value based on simple expressions using numbers, previous constants, plus the operators * and /. Parentheses are not allowed. The operator * binds more tightly than /, which may be unexpected. Thus a * b / c * d is interpreted as (a * b) / (c * d). A consequence of that is that a * b / c * d = a * b / c / d. In the value, the numbers represent rational values. So 0.3048 is interpreted as exactly 3048 / 10000. 886 887In the above case, ft2-to-m2 is a conversion constant for going from square feet to square meters. The expression evaluates to 0.09290304. Where the constants cannot be expressed as rationals, or where their interpretation is fluid, that is marked with a status value: 888 889```xml 890<unitConstant constant="PI" value="411557987 / 131002976" status='approximate' /> 891``` 892 893In such cases, software may decide to use different values for accuracy. 894 895An implementation need not use rationals directly for conversion; it could use doubles, for example, if only double accuracy is needed. 896 897### Conversion Data 898 899```xml 900<!ELEMENT convertUnits ( convertUnit* ) > 901 902<!ELEMENT convertUnit EMPTY > 903 904<!ATTLIST convertUnit source NMTOKEN #REQUIRED > 905 906<!ATTLIST convertUnit baseUnit NMTOKEN #REQUIRED > 907 908<!ATTLIST convertUnit factor CDATA #IMPLIED > 909 910<!ATTLIST convertUnit offset CDATA #IMPLIED > 911 912<!ATTLIST convertUnit special NMTOKEN #IMPLIED > 913 914<!ATTLIST convertUnit systems NMTOKENS #IMPLIED > 915 916<!ATTLIST convertUnit description CDATA #IMPLIED > 917``` 918 919The conversion data provides the data for converting all of the cldr unit identifiers to base units, and back. That allows conversion between any two convertible units, such as two units of length. For any two convertible units (such as acre and dunum) the first can be converted to the base unit (square-meter), then that base unit can be converted to the second unit. 920 921The data is expressed as conversions to the base unit from the source unit. The information can also be used for the conversion back. 922 923Examples: 924 925```xml 926<convertUnit source='carat' baseUnit='kilogram' factor='0.0002'/> 927 928<convertUnit source='gram' baseUnit='kilogram' factor='0.001'/> 929 930<convertUnit source='ounce' baseUnit='kilogram' factor='lb_to_kg/16' systems="ussystem uksystem"/> 931 932<convertUnit source='fahrenheit' baseUnit='kelvin' factor='5/9' offset='2298.35/9' systems="ussystem uksystem"/> 933``` 934 935For example, to convert from 3 carats to kilograms, the factor 0.0002 is used, resulting in 0.0006. To convert between carats and ounces, first the carets are converted to kilograms, then the kilograms to ounces (by reversing the mapping). 936 937The factor and offset use the same structure as in the value in unitConstant; in particular, * binds more tightly than /. 938 939The conversion may also require an offset, such as the following: 940 941```xml 942<convertUnit source='fahrenheit' baseUnit='kelvin' factor='5/9' offset='2298.35/9' systems="ussystem uksystem"/> 943``` 944 945The factor and offset can be simple expressions, just like the values in the unitConstants. 946 947Where a factor is not present, the value is 1; where an offset is not present, the value is 0. 948 949Instead of using `factor` and possibly `offset`, the `convertUnit` element can specify a `special` conversion that cannot be described by factor and offset (and this attribute cannot be used in conunction with factor and offset). For example: 950 951```xml 952<convertUnit source='beaufort' baseUnit='meter-per-second' special='beaufort' systems="metric_adjacent"/> 953``` 954 955The only `special` conversion currently supported is for beaufort. 956 957The `systems` attribute indicates the measurement system(s) or other characteristics of a set of unts. Multiple values may be given; for example, a unit could be marked as systems="`si_acceptable` `metric_adjacent` `prefixable`". 958 959The allowed attributes are the following: 960 961Attribute Value | Description 962------------ | ------------- 963`si` | The _International System of Units (SI)_ See [NIST Guide to the SI, Chapter 4: The Two Classes of SI Units and the SI Prefixes](https://www.nist.gov/pml/special-publication-811/nist-guide-si-chapter-4-two-classes-si-units-and-si-prefixes). Examples: meter, ampere. 964`si_acceptable` | Units acceptable for use with the SI. See [NIST Guide to the SI, Chapter 5: Units Outside the SI](https://www.nist.gov/pml/special-publication-811/nist-guide-si-chapter-5-units-outside-si). Examples: hour, liter, knot, hectare. 965`metric` | A superset of the _si_ units 966`metric_adjacent` | Units commonly accepted in some countries that follow the metric system. Examples: month, arc-second, pound-metric (= ½ kilogram), mile-scandinavian. 967`ussystem` | The inch-pound system as used in the US, also called _US Customary Units_. 968`uksystem` | The inch-pound system as used in the UK, also called _British Imperial Units_, differing mostly in units of volume 969`jpsystem` | Traditional units used in Japan. For examples, see [Japanese units of measurement](https://en.wikipedia.org/wiki/Japanese_units_of_measurement). 970`astronomical` | Additional units used in astronomy. Examples: parsec, light-year, earth-mass 971`person_age` | Special units used for people’s ages in some languages. Except for translation, they have the same system as the associated regular units. 972`currency` | Currency units. These are constructed algorithmically from the Unicode currency identifiers, and do not occur in the child elements of `convertUnits`. Examples: curr-usd (US dollar), curr-eur (Euro). 973`prefixable` | Those units that typically use SI prefixes or the [IEC binary prefixes](https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-d-bibliography#05). This can include measures like `parsec` that are not SI units. It allows implementations to group those units together, and to do sanity checks on the prefix+unit combinations, if they choose. However, implementations may choose to allow prefixes on other units, especially since there is a significant variance in usage: even a term like `megafoot` might be acceptable in some contexts. 974 975Over time, additional systems may be added, and the systems for a particular unit may be refined. 976 977#### Derived Unit System 978 979The systems attributes also apply to compound units, and are computed in the following way. 980 9811. The `prefixable` system is only applicable to base_components, and is thus removed 9822. The `number_prefixes`, `dimensionality_prefix`, `si_prefix`, and `binary_prefix` are ignored 983 * Example: systems(square-kilometer) = systems(meter) 9843. Currency units have the `currency` system 985 * Example: systems(curr-usd) = {currency} 9864. Units linked by `-and-`, `-per-`, and *adjacency* are resolved using a modified intersection, where: 987 1. The intersection of {… si …} and {… si_acceptable … } is {… si_acceptable …} 988 2. The intersection of {… metric …} and {… metric_adjacent … } is {… metric_adjacent …} 989 990Examples: 991``` 992systems(liter-per-hectare) 993 = {si_acceptable metric} ∪ {si_acceptable metric} 994 = {si_acceptable metric} 995systems(meter-per-hectare) 996 = {si metric} ∩ {si_acceptable metric} 997 = {si_acceptable metric} 998systems(mile-scandinavian-per-hour) 999 = {metric_adjacent} ∩ {si_acceptable metric_adjacent} 1000 = {metric_adjacent} 1001``` 1002 1003#### Conversion Mechanisms 1004 1005CLDR follows conversion values where possible from: 1006* [NIST Special Publication 1038](https://www.govinfo.gov/content/pkg/GOVPUB-C13-f10c2ff9e7af2091314396a2d53213e4/pdf/GOVPUB-C13-f10c2ff9e7af2091314396a2d53213e4.pdf) 1007* [International Astronomical Union General Assembly](https://arxiv.org/pdf/1510.07674.pdf) 1008 1009See also [NIST Guide to the SI, Chapter 4: The Two Classes of SI Units and the SI Prefixes](https://www.nist.gov/pml/special-publication-811/nist-guide-si-chapter-4-two-classes-si-units-and-si-prefixes) 1010 1011For complex units, such as _pound-force-per-square-inch_, the conversions are computed by combining the conversions of each of the simple units: _pound-force_ and _inch_. Because the conversions in convertUnit are reversible, the computation can go from complex source unit to complex base unit to complex target units. 1012 1013Here is an example: 1014 1015> **50 foot-per-minute ⟹ X mile-per-hour** 1016> ⟹ source: 1 foot 1017> ⟹ factor: 381 / 1250 = 0.3048 meter 1018> ⟹ source: 1 minute 1019> ⟹ factor: 60 second 1020> ⟹ intermediate: 127 / 500 = 0.254 meter-per-second 1021> ⟹ mile-per-hour 1022> ⟹ source: 1 mile 1023> ⟹ factor: 201168 / 125 = 1609.344 meter 1024> ⟹ source: 1 hour 1025> ⟹ factor: 3600 second 1026> ⟹ target: 25 / 44 ≅ 0.5681818 mile-per-hour 1027 1028**Reciprocals.** When you convert a complex unit to another complex unit, you typically convert the source to a complex base unit (like _meter-per-cubic-meter_), then convert the latter backwards to the desired target. However, there may not be a matching conversion from that complex base unit to the desired target unit. That is the case for converting from _mile-per-gallon_ (used in the US) to _liter-per-100-kilometer_ (used in Europe and elsewhere). When that happens, the reciprocal of the complex base unit is used, as in the following example: 1029 1030> **50 mile-per-gallon ⟹ X liter-per-100-kilometer** 1031> ⟹ source: 1 mile 1032> ⟹ factor: 201168 / 125 = 1609.344 meter 1033> ⟹ source: 1 gallon 1034> ⟹ factor: 473176473 / 125000000000 ≅ 0.003785412 cubic-meter 1035> ⟹ intermediate: 2400000000000 / 112903 ≅ 2.125719E7 meter-per-cubic-meter 1036> ⟹ liter-per-100-kilometer 1037> ⟹ source: 1 liter 1038> ⟹ factor: 1 / 1000 = 0.001 cubic-meter 1039> ⟹ source: 1 100-kilometer 1040> ⟹ factor: 100000 meter 1041> **⟹ 1/intermediate: 112903 / 2400000000000 ≅ 4.704292E-8 cubic-meter-per-meter** 1042> ⟹ target: 112903 / 24000 ≅ 4.704292 liter-per-100-kilometer 1043 1044This applies to more than just these cases: one can convert from any unit to related reciprocals as in the following example: 1045 1046> **50 foot-per-minute ⟹ X hour-per-mile** 1047> ⟹ source: 1 foot 1048> ⟹ factor: 381 / 1250 = 0.3048 meter 1049> ⟹ source: 1 minute 1050> ⟹ factor: 60 second 1051> ⟹ intermediate: 127 / 500 = 0.254 meter-per-second 1052> ⟹ hour-per-mile 1053> ⟹ source: 1 hour 1054> ⟹ factor: 3600 second 1055> ⟹ source: 1 mile 1056> ⟹ factor: 201168 / 125 = 1609.344 meter 1057> **⟹ 1/intermediate: 500 / 127 ≅ 3.937008 second-per-meter** 1058> ⟹ target: 44 / 25 = 1.76 hour-per-mile 1059 1060#### Exceptional Cases 1061 1062##### Identities 1063 1064For completeness, identity mappings are also provided for the base units themselves, such as: 1065 1066```xml 1067<convertUnit source='meter' baseUnit='meter' /> 1068``` 1069 1070##### Aliases 1071 1072In a few instances the old identifiers are deprecated in favor of regular syntax. Implementations should handle both on input: 1073 1074```xml 1075<unitAlias type="meter-per-second-squared" replacement="meter-per-square-second" reason="deprecated"/> 1076<unitAlias type="liter-per-100kilometers" replacement="liter-per-100-kilometer" reason="deprecated"/> 1077<unitAlias type="pound-foot" replacement="pound-force-foot" reason="deprecated"/> 1078<unitAlias type="pound-per-square-inch" replacement="pound-force-per-square-inch" reason="deprecated"/> 1079``` 1080 1081These use the standard alias elements in XML, and are also included in the [units.xml](https://github.com/unicode-org/cldr/blob/main/common/supplemental/units.xml) file. 1082 1083##### “Duplicate” Units 1084 1085Some CLDR units are provided simply because they have different names in some languages. For example, year and year-person, or foodcalorie and kilocalorie. One CLDR unit is not convertible (temperature-generic), it is only used for the translation (where the exact unit would be understood by context). 1086 1087##### Discarding Offsets 1088 1089The temperature units are special. When they represent a scale, they have an offset. But where they represent an amount, such as in complex units, they do not. So celsius-per-second is the same as kelvin-per-second. 1090 1091#### Unresolved Units 1092 1093Some SI units contain the same units in the numerator and denominator, so those cannot be resolved. For example, if cubic-meter-per-meter were always resolved, then _consumption_ (like “liter-per-kilometer”) could not be distinguished from _area_ (square-meter). 1094 1095However, in conversion, it may be necessary to resolve them in order to find a match. For example, kilowatt-hour maps to the base unit kilogram-square-meter-second-per-cubic-second, but that needs to be resolved to kilogram-square-meter-per-square-second in order matched against an _energy._ 1096 1097## Quantities and Base Units 1098 1099```xml 1100<!ELEMENT unitQuantities ( unitQuantity* ) > 1101 1102<!ELEMENT unitQuantity EMPTY > 1103 1104<!ATTLIST unitQuantity baseUnit NMTOKEN #REQUIRED > 1105 1106<!ATTLIST unitQuantity quantity NMTOKENS #REQUIRED > 1107 1108<!ATTLIST unitQuantity status NMTOKEN #IMPLIED > 1109 1110<!ATTLIST unitQuantity description CDATA #IMPLIED > 1111``` 1112 1113Conversion is supported between comparable units. Those can be simple units, such as length, or more complex ‘derived’ units that are built up from _base units_. The `<unitQuantities>` element provides information on the base units used for conversion. It also supplies information about their _quantity_: mass, length, time, etc., and whether they are simple or not. 1114 1115Examples: 1116 1117```xml 1118<unitQuantity baseUnit='kilogram' quantity='mass' status='simple'/> 1119<unitQuantity baseUnit='meter-per-second' quantity='speed'/> 1120``` 1121 1122The order of the elements in the file is significant, since it is used in [Unit_Identifier_Normalization](#Unit_Identifier_Normalization). 1123 1124The quantity values themselves are informative. For example, _force per area_ can be referenced as either _pressure_ or _stress_. The quantity for a complex unit that has a reciprocal is formed by prepending “inverse-” to the quantity, such as _inverse-consumption._ 1125 1126The base units for the quantities and the quantities themselves are based on [NIST Special Publication 811](https://www.nist.gov/pml/special-publication-811) and the earlier [NIST Special Publication 1038](https://www.govinfo.gov/content/pkg/GOVPUB-C13-f10c2ff9e7af2091314396a2d53213e4/pdf/GOVPUB-C13-f10c2ff9e7af2091314396a2d53213e4.pdf). In some cases, a different unit is chosen for the base. For example, a _revolution_ (360°) is chosen for the base unit for angles instead of the SI _radian_, and _item_ instead of the SI _mole_. Additional base units are added where necessary, such as _bit_ and _pixel_. 1127 1128This data is not necessary for conversion, but is needed for [Unit_Identifier_Normalization](#Unit_Identifier_Normalization). Some of the `unitQuantity` elements are not needed to convert CLDR units, but are included for completeness. Example: 1129 1130```xml 1131<unitQuantity baseUnit='ampere-per-square-meter' quantity='current-density'/> 1132``` 1133 1134### UnitType vs Quantity 1135 1136The unitType (as in “length-meter”) is not the same as the quantity. It is often broader: for example, the unitType _electric_ corresponds to the quantities _electric-current, electric-resistance,_ and _voltage_. The unitType itself is also informative, and can be dropped from a long unit identifier to get a still-unique short unit identifier. 1137 1138### <a name="Unit_Identifier_Normalization" href="#Unit_Identifier_Normalization">Unit Identifier Normalization</a> 1139 1140There are many possible ways to construct complex units. For comparison of unit identifiers, an implementation can normalize in the following way: 1141 11421. Convert all but the first -per- to simple multiplication. The result then has the format of /numerator ( -per- denominator)?/ 1143 * foot-per-second-per-second ⇒ foot-per-second-second 11442. Within each of the numerator and denominator: 11453. Convert multiple instances of a unit into the appropriate power. 1146 * foot-per-second-second ⇒ foot-per-square-second 1147 * kilogram-meter-kilogram ⇒ meter-square-kilogram 11484. For each single unit, disregarding prefixes and powers, get the order of the _simple_ unit among the `unitQuantity` elements in the [units.xml](https://github.com/unicode-org/cldr/blob/main/common/supplemental/units.xml). Sort the single units by that order, using a stable sort. If there are private-use single units, sort them after all the non-private use single units. 1149 * meter-square-kilogram => square-kilogram-meter 1150 * meter-square-gram ⇒ square-gram-meter 11515. As an edge case, there could be two adjacent single units with the same _simple_ unit but different prefixes, such as _meter-kilometer_. In that case, sort the larger prefixes first, such as _kilometer-meter_ or _kibibyte-kilobyte_. 11526. Within private-use single units, sort by the simple unit alphabetically. 1153 1154The examples in #4 are due to the following ordering of the `unitQuantity` elements: 1155 1156```xml 11571. <unitQuantity baseUnit='candela' quantity='luminous-intensity' status='simple'/> 11582. <unitQuantity baseUnit='kilogram' quantity='mass' status='simple'/> 11593. <unitQuantity baseUnit='meter' quantity='length' status='simple'/> 11604. … 1161``` 1162 1163## Mixed Units 1164 1165Mixed units, or unit sequences, are units with the same base unit which are listed in sequence. 1166Common examples are feet and inches; meters and centimeters; hours, minutes, and seconds; degrees, minutes, and seconds. 1167Mixed unit identifiers are expressed using the "-and-" infix, as in "foot-and-inch", "meter-and-centimeter", "hour-and-minute-and-second", "degree-and-arc-minute-and-arc-second." 1168 1169Scalar values for mixed units are expressed in the largest unit, according to the sort order discussed above in "Normalization". 1170For example, numbers for "foot-and-inch" are expressed in feet. 1171 1172Mixed unit identifiers should be from highest to lowest (eg foot-and-inch instead of inch-and-foot), and that is reflected in the display. 1173If it turns out that some locales present certain mixed units in a different order, additional structure will be needed in CLDR. 1174 1175Only the lowest unit can have decimal fractions; the higher units will be integers, so no "3.5 feet 3 inches". 1176If a number is negative, then only the highest unit shows the minus sign: eg, "-3 hours 27 minutes". 1177If one of the units is zero, then it is normally omitted: eg, "3 feet" instead of "3 feet 0 inches". 1178However, when all of the units would be omitted, then the highest unit is shown with zero: eg "0 feet". 1179 1180Implementations may offer mechanisms to control the precision of the formatted mixed unit. Examples include, but are not limited to: 1181* An implementation could apply the precision of a number formatter to the final unit. 1182 However, this mechanisim has a couple of disadvantages, such as matching precision across user preferences. For example, suppose the input amount is 1.5254 and the precision is 2 decimals. 1183 * Locale A uses decimal degrees and gets 1.53°. 1184 * Locale B uses degrees, minutes, seconds, and gets 1° 31′ 31.44″ 1185 * Locale B has an unnecessarily precise result: the equivalent of 1.52540 in precision. 1186* An implementation could allow a percentage precision; 1187 thus 1612 meters with ±1% precision would be represented by **1 mile** rather than **1 mile 9 feet**. 1188 1189The default behavior is to round the lowest unit to the nearest integer. 1190Thus 1.99959 degree-and-arc-minute-and-arc-second would be (before rounding) **1 degree 59 minutes 58.524 seconds**. 1191After rounding it would be **1 degree 59 minutes 59 seconds**. 1192 1193If the lowest unit would round to zero, or round up to the size of the next higher unit, then the next higher unit is rounded instead, recursively. 1194Thus 1.999862 degree-and-arc-minute-and-arc-second would be (before rounding) **1 degree 59 minutes 59.5032 degrees**. 1195After rounding the last unit it would be **1 degree 59 minutes 60 seconds**, which rounds up to **1 degree 60 minutes**, which rounds up to **2 degrees**. 1196This behavior can be determined before having to compute the lower units: 1197for example, where rounding to the second, if the remainder in degrees is below 1/120 degrees or above 119/120 degrees, then the degrees can be rounded without computing the minutes or seconds. 1198 1199## Testing 1200 1201The files in the directory [cldr/common/testData/units/](https://github.com/unicode-org/cldr/tree/main/common/testData/units) are provided for testing implementations. 12021. The [unitsTest.txt](https://github.com/unicode-org/cldr/blob/main/common/testData/units/unitsTest.txt) file supplies a list of all the CLDR units with conversions 12032. The [unitPreferencesTest.txt](https://github.com/unicode-org/cldr/blob/main/common/testData/units/unitPreferencesTest.txt) file supplied tests for user preferences 12043. The [unitLocalePreferencesTest.txt](https://github.com/unicode-org/cldr/blob/main/common/testData/units/unitLocalePreferencesTest.txt) file provides examples for testing the interactions between locale identifiers and unit preferences. 1205 1206Instructions for use are supplied in the header of the file. 1207 1208## <a name="Unit_Preferences" href="#Unit_Preferences">Unit Preferences</a> 1209 1210Different locales have different preferences for which unit or combination of units is used for a particular usage, such as measuring a person’s height. This is more fine-grained than merely a preference for metric versus US or UK measurement systems. For example, one locale may use meters alone, while another may use centimeters alone or a combination of meters and centimeters; a third may use inches alone, or (informally) a combination of feet and inches. 1211 1212### <a name="Unit_Preferences_Overrides" href="#Unit_Preferences_Overrides">Unit Preferences Overrides</a> 1213 1214The determination of preferred units uses the user preference data together with **input unit**, the **input usage**, and the **input locale identifer**. 1215Within the locale identifier, the subtags that can affect the result are: 1216 * the value of the keys mu, ms, and rg 1217 * the region in the locale identifier (if there is one) 1218 * and otherwise the likely region subtag for the locale identifier 1219 1220The strongest priority is the mu key, then the ms key, then the rg key. 1221Beyond that the region of the locale identifer is used, and if not present, the likely-subtag region. 1222For example: 1223 1224| | Locale | Result | Comment | 1225|---|---------------------------------------|------------|--------------------------------------------------------------------| 1226| 1 | en-u-rg-uszzzz-ms-ussystem-mu-celsius | Celsius | despite the rg and ms settings for US, and the likely region of US | 1227| 2 | en-u-rg-uszzzz-ms-metric | Celsius | despite the rg setting for US, and the likely region of US | 1228| 3 | en-u-rg-dezzzz. | Celsius | despite the likely region of US | 1229| 4 | en-DE | Celsius | because explicit region is DE | 1230| 5 | en | Fahrenheit | because the likely region for en with no region is US | 1231 1232If any key-values are invalid, then they are ignored. Thus the following constructs are ignored: 1233 1234| subtags | reason | 1235| --- | --- | 1236| -mu-smoot | invalid unit | 1237| -ms-stanford | invalid unit system | 1238| -rg-aazzzz | invalid region 'AA' ‡| 1239| -AA | invalid region 'AA'| 1240 1241‡ Only the region portion is currently used, so in -rg-usabcdef the "abcdef" is ignored, whether or not it is valid. 1242 1243The following algorithm is used to compute the override units, regions, and category. 1244The latter two items are used in the [Unit Preferences Data](#Unit_Preferences_Data). 1245 1246#### Compute override units 1247If there is a valid -mu value then let the **output unit** be the that value, and return it. 1248This terminates the algorithm; there is no need to use the unit preferences information. 1249 1250#### Compute regions 1251If there is no valid -mu value, the following steps are used to determine a region R from the **input locale identifer**. 1252(and optionally a Unit Systems Match (USM)): 1253 12541. If there is a valid -ms value then let USM be the corresponding value in column 2 of the table below. 1255Otherwise FR is not used. In either case continue with step 2. 12562. If there is a valid -rg region, let R be that region, and go to Compute the category. 12573. If there is a valid region in the locale, let R be that region, and go to Compute the category. 12584. Otherwise, compute the likely subtags for the locale. 1259 1. If there is a likely region, then let R be that region, and go to Compute the category. 1260 2. Otherwise, let R be 001, and go to Compute the category 1261 1262| Key-Value | Unit Systems Match | Fallback Region for Unit Preferences | 1263|-------------|-----------------------------|--------------------------------------| 1264| ms-metric | metric OR metric_adjacent | 001 | 1265| ms-ussystem | ussystem | US | 1266| ms-uksystem | uksystem | UK | 1267 1268#### Compute the category 1269 1270A **category** is determined as follows from the input unit: 1271 12721. From the input unit, use the conversion data in [baseUnit](tr35-info.md#Unit_Conversion) and let the **input base unit** be the baseUnit attribute value. 1273 * eg, for `pound-force` the baseUnit is `kilogram-meter-per-square-second`. 12742. If there is no such base unit (such as for a an unusual unit like `ampere-pound-per-foot-square-minute`), 1275 convert the input unit to a combination of base units, reduce to lowest terms, and normalize. 1276 Let the **input base unit** be that value. 1277 * eg, `ampere-pound-per-foot-square-minute` ⇒ `kilogram-ampere-per-meter-square-second` 12783. If the **input base unit** has a unitQuantity element, then let the **category** be the quantity attribute value. 1279 * eg, `force` from `<unitQuantity baseUnit='kilogram-meter-per-square-second' quantity='force'/>` 12804. If the **input base unit** does not have a unitQuantity, let the output unit be the input base unit. 1281 An implementation may also set it to an equivalent metric/SI unit, as in the example below. 1282 This terminates the algorithm; there is no need to use the unit preferences information. 1283 * For example, for `ampere-pound-per-foot-square-minute` an implementation could return `kilogram-ampere-per-meter-square-second` or `pascal-ampere`. 1284 * That is, an implementation can use shorter metric/SI units as long as long as the combination is equivalent in value. 1285 1286### <a name="Unit_Preferences_Data" href="#Unit_Preferences_Data">Unit Preferences Data</a> 1287 1288The CLDR data is intended to map from a particular usage — e.g. measuring the height of a person or the fuel consumption of an automobile — to the unit or combination of units typically used for that usage in a given region. Considerations for such a mapping include: 1289 1290* The list of possible usages is large and open-ended, and will be extended in the future. 1291* Even for a given usage such a measuring a road distance, there are different choices of units based on the particular distance. 1292 For example, one set of units may be used for indicating the distance to the next city (kilometers or miles), while another may be used for indicating the distance to the next exit (meters, yards, or feet). 1293* There are also differences between more formal usage (official signage, medical records) and more informal usage (conversation, texting). 1294* For some usages, the measurement may be expressed using a sequence of units, such as “1 meter, 78 centimeters” or “12 stone, 2 pounds”. 1295 1296The DTD structure is as follows: 1297 1298```xml 1299<!ELEMENT unitPreferenceData ( unitPreferences* ) > 1300 1301<!ELEMENT unitPreferences ( unitPreference* ) > 1302<!ATTLIST unitPreferences category NMTOKEN #REQUIRED > 1303<!ATTLIST unitPreferences usage NMTOKENS #REQUIRED > 1304 1305<!ELEMENT unitPreference ( #PCDATA ) > 1306<!ATTLIST unitPreference regions NMTOKENS #REQUIRED > 1307<!ATTLIST unitPreference geq NMTOKEN #IMPLIED > 1308<!ATTLIST unitPreference skeleton CDATA #IMPLIED > 1309``` 1310 1311| Term | Description | 1312|---|---| 1313| category | A unit quantity, such as “area” or “length”. See [Unit Conversion](#Unit_Conversion) | 1314| usage | A type of usage, such as person-height. | 1315| regions | One or more region identifiers (macroregions or regions), such as 001, US. (Note that this field may be extended in the future to also include subdivision identifiers and/or language identifiers, such as usca, and de-CH.) | 1316| geq | A threshold value, in a unit determined by the unitPreference element value. The unitPreference element is only used for values higher than this value (and lower than any higher value).<br/>The value must be non-negative. For picking negative units (-3 meters), use the absolute value to pick the unit. | 1317| skeleton | A skeleton in the ICU number format syntax, that is to be used to format the output unit amount. | 1318 1319 1320Logically, the unit preferences data is a map from categories to a map of usages to a map of regions to a list of ranked units and optional formats. 1321 1322**Note:** As of CLDR 37, the `<unitPreference>` `geq` attribute replaces the now-deprecated `<unitPreferences>` `scope` attribute. 1323 1324#### Examples: 1325 1326```xml 1327<unitPreferences category="length" usage="default"> 1328 <unitPreference regions="001">kilometer</unitPreference> 1329 <unitPreference regions="001">meter</unitPreference> 1330 <unitPreference regions="001">centimeter</unitPreference> 1331 <unitPreference regions="US GB">mile</unitPreference> 1332 <unitPreference regions="US GB">foot</unitPreference> 1333 <unitPreference regions="US GB">inch</unitPreference> 1334</unitPreferences> 1335``` 1336 1337The above information says that for default usage, in the US people use mile, foot, and inch, where people in the rest of the world (001) use kilometer, meter, and centimeter. Take another example: 1338 1339```xml 1340<unitPreferences category="length" usage="road"> 1341 <unitPreference regions="001" geq="0.9">kilometer</unitPreference> 1342 <unitPreference regions="001" geq="300.0" skeleton="precision-increment/50">meter</unitPreference> 1343 <unitPreference regions="001" skeleton="precision-increment/10">meter</unitPreference> 1344 <unitPreference regions="001">meter</unitPreference> 1345 <unitPreference regions="US" geq="0.5">mile</unitPreference> 1346 <unitPreference regions="US" geq="100.0" skeleton="precision-increment/50">foot</unitPreference> 1347 <unitPreference regions="US" skeleton="precision-increment/10">foot</unitPreference> 1348 <unitPreference regions="GB" geq="0.5">mile</unitPreference> 1349 <unitPreference regions="GB" geq="100.0" skeleton="precision-increment/50">yard</unitPreference> 1350 <unitPreference regions="GB">yard</unitPreference> 1351 <unitPreference regions="SE" geq="0.1">mile-scandinavian</unitPreference> 1352</unitPreferences> 1353``` 1354 1355The following is the algorithm for computing the preferred output unit from the category, usage, region, and USM. 1356 1357#### Compute the preferred output unit 1358 13591. Let category preferences be the result of a lookup of **category** in the unit preferences. 1360 1. If the lookup fails, let the **output unit** be the input base unit or an equivalent metric/SI unit, and return. This terminates the algorithm. 13612. Let category-usage preferences be the result of a lookup of **input usage** in the category preferences. 1362 1. If the lookup fails, let the **input usage** be its containing usage, and repeat. (This will always terminate is always a 'default' usage for each category.) 1363 2. The containing usage is the result of truncating the last '-' and following text, if there is a '-', and other wise 'default' 1364 * For example, land-agriculture-grain ⊂ land-agriculture ⊂ land ⊂ default 13653. Let ranked units be the result of a lookup of R in the category-usage preferences. There may be both region values and [containment regions](https://www.unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html). 1366 1. If the lookup of R fails, set R to its containing region and repeat. (This will always terminate because 001 is always present.) 1367 * For example, CH (Switzerland) ⊂ 155 (Western Europe) ⊂ 150 (Europe) ⊂ 001 (World). 1368 * This loop can be optimized to only include containing regions that occur in the data (eg, only 001 in LDML 45). 13694. If there is a USM, and the corresponding Fallback Region is different than R, and any of the units in the ranked list don't match the USM, then let the ranked units be the result of a lookup of the Fallback Region in the category-usage preferences. 1370 1371#### Search the ranked units 1372 1373The ranked units will be of the following form: 1374 ```xml 1375 <unitPreference regions="GB" geq="0.5">mile</unitPreference> 1376 <unitPreference regions="GB" geq="100.0" skeleton="precision-increment/50">yard</unitPreference> 1377 <unitPreference regions="GB">yard</unitPreference> 1378 ``` 1379 1380* The geq item gives the value for the unit in the element value (or for the largest unit for mixed units). For example, 1381 * `...geq="0.5">mile<...` is ≥ 0.5 miles 1382 * `...geq="100.0">foot-and-inch<...` is ≥ 100 feet 1383* If there is no `geq` attribute, then the implicit value is 1.0. 1384* Implementations will probably convert the values into the base units, so that the comparison is fast. Thus the above would be converted internally to something like: 1385 * ≥ 804.672 meters ⇒ mile 1386 * ≥ 30.48 meters ⇒ foot-and-inch 1387 13881. Search for the first matching unitPreference for the absolute value of the input measure. If there is no match (eg < 100 feet in the above example), take the last unitPreference. That is, the last unitPreference is effectively geq="0". In the above example, `<unitPreference regions="GB">yard</unitPreference>` is equivalent to `<unitPreference geq="0" regions="GB">yard</unitPreference>` 1389 1390For completeness, when comparing doubles to the geq values: 1391* Negative numbers are treated as if they were positive, so in the above example -804.672 meters will format as "-0.5 mile". 1392* _infinity_, NaN, and -_infinity_ match the largest possible value. Thus -∞ meters will format as "-∞ miles", not "-∞ yards". 1393 13942. Once a matching `unitPreference` element is found: 1395 1396* The unit is the element value 1397* The skeleton (if there is one) supplies formatting information for the unit. API settings may allow that to be overridden. 1398 * The syntax and semantics for the skeleton value are defined by the [ICU Number Skeletons](https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html) document. 1399* If the skeleton is missing, the default is skeleton="**precision-integer/@@\***". However, the client can also override or tune the number formatting. 1400* If the unit is mixed (eg foot-and-inch) the skeleton applies to the final subunit; the higher subunits are formatted as integers. 1401 1402### Constraints 1403 1404* For a given category, there is always a “default” usage. 1405* For a given category and usage: 1406 * There is always a 001 region. 1407 * None of the sets of regions can overlap. That is, you can’t have “US” on one line and “US GB” on another. You _can_ have two lines with “US”, for different sizes of units. 1408* For a given category, usage, and region-set 1409 * The unitPreferences are in descending order. 1410 1411#### Examples 1412 1413**Example A: xx-SE-u-ms-metric, length, road** 14141. Fetch the data from `<unitPreferences category="length" usage="road">` for xx-SE 1415``` 1416<unitPreference regions="SE">mile-scandinavian</unitPreference> 1417<unitPreference regions="SE">kilometer</unitPreference> 1418<unitPreference regions="SE" geq="300.0" skeleton="precision-increment/50">meter</unitPreference> 1419<unitPreference regions="SE" geq="10" skeleton="precision-increment/10">meter</unitPreference> 1420<unitPreference regions="SE" skeleton="precision-increment/1">meter</unitPreference> 1421``` 14222. Meter is **metric**, mile-scandinavian is **metric_adjacent** so they both match the key-value ms-**metric**, so no change is made. 1423 1424**Example B: xx-GB-u-ms-ussystem, volume, fluid** 14251. Fetch the data from `<unitPreferences category="volume" usage="fluid">` for xx-GB 1426``` 1427<unitPreference regions="GB">gallon-imperial</unitPreference> 1428<unitPreference regions="GB">fluid-ounce-imperial</unitPreference> 1429``` 14302. At least one of {gallon-imperial, fluid-ounce-imperial} does not match ms-**ussystem** so the locale is shifted to xx-**US**, and uses the following: 1431``` 1432<unitPreference regions="US">gallon</unitPreference> 1433<unitPreference regions="US">quart</unitPreference> 1434<unitPreference regions="US">pint</unitPreference> 1435<unitPreference regions="US">cup</unitPreference> 1436<unitPreference regions="US">fluid-ounce</unitPreference> 1437<unitPreference regions="US">tablespoon</unitPreference> 1438<unitPreference regions="US">teaspoon</unitPreference> 1439``` 1440 1441## Unit APIs 1442APIs should clearly allow for both the use of unit preferences with the above process, and for the _invariant use_ of a unit measure. 1443That is, while an application will usually want to obey the preferences for the locale or in the locale ID, there will definitely be instances where it will want to not use them. 1444For example, in showing the weather, an application may want to show: 1445 1446High today: 68°F (20°C) 1447 1448To do that, the application needs to show the first value with the locale information, and then (a) query what the alternative is, and show the temperature in that. 1449As an example, ICU only uses the unit preferences (with rg, ms, and/or mu and the likely region) in formatting units when a **usage** parameter is set. 1450 1451* * * 1452 1453Copyright © 2001–2024 Unicode, Inc. All Rights Reserved. The Unicode Consortium makes no expressed or implied warranty of any kind, and assumes no liability for errors or omissions. No liability is assumed for incidental and consequential damages in connection with or arising out of the use of the information or programs contained or accompanying this technical report. The Unicode [Terms of Use](https://www.unicode.org/copyright.html) apply. 1454 1455Unicode and the Unicode logo are trademarks of Unicode, Inc., and are registered in some jurisdictions. 1456