-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Short Compact Currency Formatter Provider and Populate Associated Data #5361
Conversation
/// `"1000-count-one-alt-alphaNextToNumber": "¤ 0K"` | ||
/// -> key1 = 3, key2 = CompactCount::OneAlt, value = "¤ 0K" | ||
#[cfg_attr(feature = "serde", serde(borrow))] | ||
pub compact_patterns: ZeroMap2d<'data, i8, CompactCount, str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless you need to do the lookup in two steps, prefer ZeroMap<(i8, CompactCount), str>
over ZeroMap2d
, as the 2d version has bigger metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fn try_from(value: &str) -> Result<Self, Self::Error> { | ||
match value { | ||
"zero" => Ok(CompactCount::Zero), | ||
"zero-alt-alphaNextToNumber" => Ok(CompactCount::ZeroAlt), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is highly CLDR-JSON specific and should live in icu_provider_source
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/// CompactPattern `zero`. | ||
Zero = 0, | ||
/// Compact Pattern `zero` alternative. | ||
ZeroAlt = 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how will the Alt data be accessed? Consider putting them behind a locale variant instead (i.e. en-gb-alt
), instead of modelling them in the same data struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, we made it AlphaNextToNumber
@@ -33,11 +33,9 @@ pub struct ShortCurrencyCompactV1<'data> { | |||
/// `"1000-count-one-alt-alphaNextToNumber": "¤ 0K"` | |||
/// -> key1 = 3, key2 = CompactCount::OneAlt, value = "¤ 0K" | |||
#[cfg_attr(feature = "serde", serde(borrow))] | |||
pub compact_patterns: ZeroMap2d<'data, i8, CompactCount, str>, | |||
pub compact_patterns: ZeroMap<'data, (i8, CompactCount), str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have 4 bits left in CompactCountULE
, what's the range of the log10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no limit for log10, but I think to put the limit 16
is kinda a low limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it'd be -8 to 7 as well.
@@ -46,56 +44,35 @@ pub struct ShortCurrencyCompactV1<'data> { | |||
databake(path = icu_experimental::dimension::provider::currency_compact) | |||
)] | |||
#[repr(u8)] | |||
pub enum CompactCount { | |||
pub enum Count { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use an existing Count
? This type exists at least twice already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and #5373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you just moved it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still things that I'd like addressed and I'm trusting you to follow up on them.
@@ -33,11 +33,9 @@ pub struct ShortCurrencyCompactV1<'data> { | |||
/// `"1000-count-one-alt-alphaNextToNumber": "¤ 0K"` | |||
/// -> key1 = 3, key2 = CompactCount::OneAlt, value = "¤ 0K" | |||
#[cfg_attr(feature = "serde", serde(borrow))] | |||
pub compact_patterns: ZeroMap2d<'data, i8, CompactCount, str>, | |||
pub compact_patterns: ZeroMap<'data, (i8, CompactCount), str>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it'd be -8 to 7 as well.
@@ -46,56 +44,35 @@ pub struct ShortCurrencyCompactV1<'data> { | |||
databake(path = icu_experimental::dimension::provider::currency_compact) | |||
)] | |||
#[repr(u8)] | |||
pub enum CompactCount { | |||
pub enum Count { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you just moved it?
Tasks
In this PR, the following tasks are accomplished:
numbers.json
.ShortCompactCurrencyV1
struct.bakeddata
andtestdata
forShortCompactCurrencyV1Marker
.