Implement Into<Locale> for preference structs.#7622
Implement Into<Locale> for preference structs.#7622jedel1043 wants to merge 4 commits intounicode-org:mainfrom
Into<Locale> for preference structs.#7622Conversation
8d21fad to
a6a54ba
Compare
sffc
left a comment
There was a problem hiding this comment.
Thanks! Would you mind adding some round-trip test cases?
| $( | ||
| if let Some(value) = other.$key { | ||
| if let Some(ue) = <$pref>::unicode_extension_key() { | ||
| let val = value.unicode_extension_value().unwrap(); |
There was a problem hiding this comment.
Question/Issue: Will every value always have a unicode extension value?
|
I don't think this makes much sense conceptually. A locale that is obtained from say |
|
The use case is new Intl.DateTimeFormat("en-u-ca-chinese-co-pinyin").resolvedOptions().locale
// 'en-u-ca-chinese' |
|
Preferences are not designed to be the resolved options, they are not aware of any fallback that happens. Does It's very counterintuitive for |
|
It appears to do filtering of relevant extension keywords, removing unsupported values, and resolving aliases. new Intl.DateTimeFormat("en-u-ca-ethiopic-amete-alem-co-pinyin-nu-latn1").resolvedOptions().locale
'en-u-ca-ethioaa' |
Well, preference-to-locale is the lossless direction. The direction we currently have is the lossy direction.
I am always happy with concrete functions over
We could do both, but I see no good reason to export Writeable without exporting the Locale conversion, since you can re-parse the writeable into a Locale and just be less efficient. |
You can't really talk about lossless if you only have one direction. Right now, we have a Locale domain A and a preferences domain B (which is different from A).
Yes, but using that |
|
@robertbastian Hmm, what about only implementing a conversion into |
|
I would approve |
|
A potential issue with that signature is whether we should include -u-rg and -u-sd in the keywords. If we don't include them, then we aren't including all the keywords. If we do include them, then we aren't returning all of the region information. |
|
If it's lossy perhaps we should have |
can you elaborate what you mean by this? we're returning all unicode keywords that are relevant to the preferences |
The Preferences struct contains LocalePreferences plus zero or more keywords relevant to the formatter. It seems wrong to pull only some of the data out of LocalePreferences without returning all of the data from LocalePreferences. |
This will simplify boa-dev/boa#4589 in the future.