CLDR-19737 Improve Unit Preferences Data consistency - #6075
Conversation
| ``` | ||
|
|
||
| The 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: | ||
| The above information says that for default usage, in the US and UK (region “GB”) people use mile, foot, and inch, while people in the rest of the world (region “001”) use kilometer, meter, and centimeter. Take another example: |
There was a problem hiding this comment.
UK uses metric for a lot of things. I'm not sure the UK should be included here. Maybe it should have a 'for example' before the US section or something similar?
Also I don't think we should list the region 001. I believe this was intentionally a generic reference. Depending on the unit there is a lot more nuance for unit defaults.
There was a problem hiding this comment.
It's describing the existing example at https://unicode.org/reports/tr35/tr35-info.html#examples , which seems to not be generic, but is currently doing so inaccurately. Is there a better example to use?
There was a problem hiding this comment.
I guess it makes sense. We may want to update the "road" example further down since the supplemental data for that item is now more extensive: https://github.com/unicode-org/cldr/blob/main/common/supplemental/units.xml#L481
Interestingly for some units it it "GB US" and others are "US GB". I think we may want to add a test to require consistent ordering in the region names unless there is a specific reason that one region must be first in the list.
There was a problem hiding this comment.
I will think about whether there is a way to expand the explanation about "default usage" since there are many use cases in the UK where the default is not the expected behavior unlike the US.
There was a problem hiding this comment.
It is normal for any usage="default" for there to be additional unitPreferences with the same category (such as "length") that have different behavior for that locale (road, beer, etc.) Maybe we should make that clearer in the spec.
stenshamn
left a comment
There was a problem hiding this comment.
Just some formatting suggestions.
| | usage | A type of usage, such as person-height. | | ||
| | 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.) | | ||
| | 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. | | ||
| | regions | One or more region identifiers (macroregions or regions), such as “001” or “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”.) | |
There was a problem hiding this comment.
| | regions | One or more region identifiers (macroregions or regions), such as “001” or “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”.) | | |
| | regions | One or more region identifiers (macroregions or regions), such as `001` or `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`.) | |
There was a problem hiding this comment.
We have to keep the bcp-47 formatting so we need to keep it as 'de-CH' not de_CH.
If we want to update how specific items are called out, we may want to do that all in one PR that is separate from content updates so that we're consistent across the spec.
| ``` | ||
|
|
||
| The 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: | ||
| The above information says that for default usage, in the US and UK (region “GB”) people use mile, foot, and inch, while people in the rest of the world (region “001”) use kilometer, meter, and centimeter. Take another example: |
There was a problem hiding this comment.
| The above information says that for default usage, in the US and UK (region “GB”) people use mile, foot, and inch, while people in the rest of the world (region “001”) use kilometer, meter, and centimeter. Take another example: | |
| The above information says that for default usage, in the US and UK (region `GB`) people use mile, foot, and inch, while people in the rest of the world (region `001`) use kilometer, meter, and centimeter. Take another example: |
There was a problem hiding this comment.
We have a bit of a hodge-podge of styles for different entities (dating back to well before our source was in markdown). At most we can be "locally" consistent right now.
I think the first step would be to come up with a set of recommended styles, such as:
element
"en-Latn" (or en-Latn) ...
(one I've seen before is element@attribute for the ID, with the "element" part dropped where unambiguous)
We can then apply that to the spec text (eg, incrementally)
| 2. The containing usage is the result of truncating the last '-' and following text, if there is a '-', and other wise 'default' | ||
| 1. If the lookup fails, let the **output unit** be the base unit of the input measure or an equivalent metric/SI unit, and return. This terminates the algorithm. | ||
| 2. Let category-usage preferences be the result of a lookup of **usage** in the category preferences. | ||
| 1. If the lookup fails, set **usage** to its containing usage and repeat. (This will always terminate because usage “default” is always present for each category.) |
There was a problem hiding this comment.
| 1. If the lookup fails, set **usage** to its containing usage and repeat. (This will always terminate because usage “default” is always present for each category.) | |
| 1. If the lookup fails, set **usage** to its containing usage and repeat. (This will always terminate because usage `default` is always present for each category.) |
| 1. If the lookup fails, let the **output unit** be the base unit of the input measure or an equivalent metric/SI unit, and return. This terminates the algorithm. | ||
| 2. Let category-usage preferences be the result of a lookup of **usage** in the category preferences. | ||
| 1. If the lookup fails, set **usage** to its containing usage and repeat. (This will always terminate because usage “default” is always present for each category.) | ||
| 2. The containing usage is the result of truncating the last '-' and following text, if there is a '-', and otherwise is “default”. |
There was a problem hiding this comment.
| 2. The containing usage is the result of truncating the last '-' and following text, if there is a '-', and otherwise is “default”. | |
| 2. The containing usage is the result of truncating the last `-` and following text, if there is a `-`, and otherwise is `default`. |
| 3. 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). | ||
| 1. If the lookup of R fails, set R to its containing region and repeat. (This will always terminate because 001 is always present.) | ||
| 3. Let ranked units be the result of a lookup of **region** 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). | ||
| 1. If the lookup fails, set **region** to its containing region and repeat. (This will always terminate because region “001” is always present.) |
There was a problem hiding this comment.
| 1. If the lookup fails, set **region** to its containing region and repeat. (This will always terminate because region “001” is always present.) | |
| 1. If the lookup fails, set **region** to its containing region and repeat. (This will always terminate because region `001` is always present.) |
| * ≥ 30.48 meters ⇒ foot-and-inch | ||
|
|
||
| 1. 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>` | ||
| 1. Let V be the absolute value of the input measure. If the input measure is NaN, let V be _infinity_. (so a non-finite input measure matches the largest possible value, e.g. -∞ meters will format as “-∞ miles”.) |
There was a problem hiding this comment.
| 1. Let V be the absolute value of the input measure. If the input measure is NaN, let V be _infinity_. (so a non-finite input measure matches the largest possible value, e.g. -∞ meters will format as “-∞ miles”.) | |
| 1. Let V be the absolute value of the input measure. If the input measure is NaN, let V be _infinity_ (so a non-finite input measure matches the largest possible value, e.g. -∞ meters will format as “-∞ miles”). |
There was a problem hiding this comment.
This change would be inconsistent with the rest of the document (and with the other documents constituting UTS #35).
| * 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. | ||
| * For a given category, usage, and region-set | ||
| * The unitPreferences are in descending order. | ||
| * There is always a “001” region. |
There was a problem hiding this comment.
| * There is always a “001” region. | |
| * There is always a `001` region. |
Co-authored-by: Fredrik <stenshamn@apple.com>
CLDR-19737
ALLOW_MANY_COMMITS=true