Skip to content

Commit 6f0bba3

Browse files
authored
CLDR-17298 Update syntax to permit constants not followed by a unit (#3727)
1 parent e2e5063 commit 6f0bba3

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

docs/ldml/tr35-general.md

+24-18
Original file line numberDiff line numberDiff line change
@@ -909,12 +909,12 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
909909
<!-- HTML: no header -->
910910

911911
<table><tbody>
912-
<tr><td>unit_identifier</td><td>:=</td>
912+
<tr><td><a name='unit_identifier' href='unit_identifier'>unit_identifier</a></td><td>:=</td>
913913
<td>core_unit_identifier<br/>
914914
| mixed_unit_identifier<br/>
915915
| long_unit_identifier</td></tr>
916916

917-
<tr><td>core_unit_identifier</td><td>:=</td>
917+
<tr><td><a name='core_unit_identifier' href='core_unit_identifier'>core_unit_identifier</a></td><td>:=</td>
918918
<td>product_unit ("-" per "-" product_unit)*<br/>
919919
| per "-" product_unit ("-" per "-" product_unit)*
920920
<ul><li><em>Examples:</em>
@@ -930,16 +930,16 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
930930
<li><em>Constraint:</em> The token 'per' is the single value in &lt;unitIdComponent type="per"&gt;</li>
931931
</ul></td></tr>
932932

933-
<tr><td>product_unit</td><td>:=</td>
933+
<tr><td><a name='product_unit' href='product_unit'>product_unit</a></td><td>:=</td>
934934
<td>single_unit ("-" single_unit)* ("-" pu_single_unit)*<br/>
935935
| pu_single_unit ("-" pu_single_unit)*
936936
<ul><li><em>Example:</em> foot-pound-force</li>
937937
<li><em>Constraint:</em> No pu_single_unit may precede a single unit</li>
938938
</ul></td></tr>
939939

940-
<tr><td>single_unit</td><td>:=</td>
941-
<td>number_prefix? dimensionality_prefix? simple_unit
942-
<ul><li><em>Examples: </em>square-meter, or 100-square-meter</li></ul></td></tr>
940+
<tr><td><a name='single_unit' href='single_unit'>single_unit</a></td><td>:=</td>
941+
<td>dimensionality_prefix? simple_unit | unit_constant
942+
<ul><li><em>Examples: </em>square-kilometer, or 100</li></ul></td></tr>
943943

944944
<tr><td>pu_single_unit</td><td>:=</td>
945945
<td>"xxx-" single_unit | "x-" single_unit
@@ -948,25 +948,27 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
948948
<li>See <a href="#Private_Use_Units">Private-Use Units</a></li>
949949
</ul></td></tr>
950950

951-
<tr><td>number_prefix</td><td>:=</td>
952-
<td>("1"[0-9]+ | [2-9][0-9]*) "-"
951+
<tr><td><a name='unit_constant' href='unit_constant'>unit_constant</a></td><td>:=</td>
952+
<td>("1"[0-9]+ | [2-9][0-9]*)("e" ("1"[0-9]+ | [2-9][0-9]*))?
953953
<ul><li><em>Examples:</em>
954954
<ul><li>kilowatt-hour-per-100-kilometer</li>
955955
<li>gallon-per-100-mile</li>
956956
<li>per-200-pound</li>
957+
<li>per-12</li>
957958
</ul></li>
958959
<li><em>Note:</em> The number is an integer greater than one.</li>
960+
<li><em>Note:</em> The <code>e</code> notation is optional: per-100-kilometer and per-1e2-kilometer are equivalent unit_identifiers.</li>
959961
</ul></td></tr>
960962

961-
<tr><td>dimensionality_prefix</td><td>:=</td>
963+
<tr><td><a name='dimensionality_prefix' href='dimensionality_prefix'>dimensionality_prefix</a></td><td>:=</td>
962964
<td>"square-"<p>| "cubic-"<p>| "pow" ([2-9]|1[0-5]) "-"
963965
<ul>
964966
<li><em>Constraint:</em> must be value in: &lt;unitIdComponent type="power"&gt;.</li>
965967
<li><em>Note:</em> "pow2-" and "pow3-" canonicalize to "square-" and "cubic-"</li>
966968
<li><em>Note:</em> These are values in &lt;unitIdComponent type="power"&gt;</li>
967969
</ul></td></tr>
968970

969-
<tr><td>simple_unit</td><td>:=</td>
971+
<tr><td><a name='simple_unit' href='simple_unit'>simple_unit</a></td><td>:=</td>
970972
<td>(prefix_component "-")* (prefixed_unit | base_component) ("-" suffix_component)*<br/>
971973
| currency_unit<br/>
972974
| "em" | "g" | "us" | "hg" | "of"
@@ -979,16 +981,18 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
979981
<tr><td>prefixed_unit</td><td></td>
980982
<td>prefix base_component<ul><li><em>Example: </em>kilometer</li></ul></td></tr>
981983

982-
<tr><td>prefix</td><td></td>
984+
<tr><td><a name='prefix' href='prefix'>prefix</a></td><td></td>
983985
<td>si_prefix | binary_prefix</td></tr>
984986

985987
<tr><td>si_prefix</td><td>:=</td>
986988
<td>"deka" | "hecto" | "kilo", …
987-
<ul><li><em>Note:</em> See full list at <a href="https://www.nist.gov/pml/special-publication-811">NIST special publication 811</a></li></ul></td></tr>
989+
<ul><li><em>Constraint:</em> Must be an attribute value of the <code>type</code> in: &lt;unitPrefix type='…' … power10='…'&gt;.
990+
See also <a href="https://www.nist.gov/pml/special-publication-811">NIST special publication 811</a></li></ul></td></tr>
988991

989992
<tr><td>binary_prefix</td><td>:=</td>
990993
<td>"kibi", "mebi", …
991-
<ul><li><em>Note:</em> See full list at <a href="https://physics.nist.gov/cuu/Units/binary.html">Prefixes for binary multiples</a></li></ul></td></tr>
994+
<ul><li><em>Constraint:</em> Must be an attribute value of the <code>type</code> in: &lt;unitPrefix type='…' … power2='…'&gt;.
995+
See also <a href="https://physics.nist.gov/cuu/Units/binary.html">Prefixes for binary multiples</a></li></ul></td></tr>
992996

993997
<tr><td>prefix_component</td><td>:=</td>
994998
<td>[a-z]{3,∞}
@@ -1016,7 +1020,7 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
10161020
<li><em>Constraint:</em> must be value in: &lt;unitIdComponent type="suffix"&gt;</li>
10171021
</ul></td></tr>
10181022

1019-
<tr><td>mixed_unit_identifier</td><td>:=</td>
1023+
<tr><td><a name='mixed_unit_identifier' href='mixed_unit_identifier'></a></td><td>:=</td>
10201024
<td>(single_unit | pu_single_unit) ("-" and "-" (single_unit | pu_single_unit ))*
10211025
<ul><li><em>Example: foot-and-inch</em></li>
10221026
</ul></td></tr>
@@ -1033,7 +1037,7 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
10331037
<tr><td>grouping</td><td>:=</td>
10341038
<td>[a-z]{3,∞}</td></tr>
10351039

1036-
<tr><td>currency_unit</td><td>:=</td>
1040+
<tr><td><a name='currency_unit' href='currency_unit'>currency_unit</a></td><td>:=</td>
10371041
<td>"curr-" [a-z]{3}
10381042
<ul>
10391043
<li><em>Constraint:</em> The first part of the currency_unit is a standard prefix; the second part of the currency unit must be a valid <a href="tr35.md#UnicodeCurrencyIdentifier">Unicode currency identifier</a>.</li>
@@ -1047,7 +1051,9 @@ Some of the constraints reference data from the unitIdComponents in [Unit_Conver
10471051

10481052
</tbody></table>
10491053

1050-
Note that while the syntax allows for number_prefixes in multiple places, the typical use case is only one instance, after a "-per-".
1054+
Note that while the syntax allows for unit_constants in multiple places, the typical use case is only one instance, after a "-per-".
1055+
The normalized form of a unit identifier has at most one unit_constant in the numerator and one in the denominator.
1056+
For example, `2-kilowatt-7-hour-per-3-meter-5-second` has the equivalent normalized form `14-kilowatt-hour-per-15-meter-second`.
10511057

10521058
The simple_unit structure does not allow for any two simple_units to overlap.
10531059
That is, there are no cases where simple_unit1 consists of X-Y and simple_unit2 consists of Y-Z.
@@ -1322,12 +1328,12 @@ If there is no precomputed form, the following process in pseudocode is used to
13221328
2. set singlePluralCategory to be power0(singlePluralCategory)
13231329
3. set singleCaseVariant to be power0(singleCaseVariant)
13241330
4. remove the dimensionality_prefix from singleUnit
1325-
4. if singleUnit starts with an si_prefix, such as 'centi' and/or a number_prefix such as '100'
1331+
4. if singleUnit starts with an si_prefix, such as 'centi' and/or a unit_constant such as '100'
13261332
1. set siPrefixPattern to be getValue(that si_prefix, locale, length), such as "centy{0}"
13271333
2. set singlePluralCategory to be prefix0(singlePluralCategory)
13281334
3. set singleCaseVariant to be prefix0(singleCaseVariant)
13291335
4. remove the si_prefix from singleUnit
1330-
5. set multiplier to be the locales integer numberFormat of number_prefix.
1336+
5. set multiplier to be the locales integer numberFormat of unit_constant.
13311337
5. Set corePattern to be the getValue(singleUnit, locale, length, singlePluralCategory, singleCaseVariant), such as "{0} metrem"
13321338
6. Extract(corePattern, coreUnit, placeholder, placeholderPosition) from that pattern.
13331339
7. If the position is _middle_, then fail

0 commit comments

Comments
 (0)