Skip to content

CLDR-19737 Improve Unit Preferences Data consistency - #6075

Open
gibson042 wants to merge 2 commits into
unicode-org:mainfrom
gibson042:cldr-19737-uts-35-unit-preferences-data-cleanup
Open

CLDR-19737 Improve Unit Preferences Data consistency#6075
gibson042 wants to merge 2 commits into
unicode-org:mainfrom
gibson042:cldr-19737-uts-35-unit-preferences-data-cleanup

Conversation

@gibson042

Copy link
Copy Markdown
Contributor

CLDR-19737

  • This PR completes the ticket.

ALLOW_MANY_COMMITS=true

Comment thread docs/ldml/tr35-info.md
```

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:

@AEApple AEApple Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@AEApple AEApple Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 stenshamn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some formatting suggestions.

Comment thread docs/ldml/tr35-info.md
| 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.) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| 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`.) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/ldml/tr35-info.md Outdated
Comment thread docs/ldml/tr35-info.md
```

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

@macchiati macchiati Aug 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread docs/ldml/tr35-info.md
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.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.)

Comment thread docs/ldml/tr35-info.md
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”.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.

Comment thread docs/ldml/tr35-info.md
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.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.)

Comment thread docs/ldml/tr35-info.md
* ≥ 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”.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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”).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would be inconsistent with the rest of the document (and with the other documents constituting UTS #35).

Comment thread docs/ldml/tr35-info.md
* 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* There is always a 001 region.
* There is always a `001` region.

Co-authored-by: Fredrik <stenshamn@apple.com>
@gibson042
gibson042 deployed to spec-preview August 20, 2026 19:36 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants