You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We do not currently have percentage formatting. We will need it for ECMA-402 compatibility.
We can do this in the scope of measurement unit formatting, but I think it would be useful to have a standalone percentage formatter since this is how it worked in previous versions of ECMA-402.
As a first step, we can make a data struct, probably in the icu_dimension crate.
The text was updated successfully, but these errors were encountered:
Specifically for the percent formatter: you can create a data struct in experimental/dimension/src/provider.rs, something like this:
#[icu_provider::data_struct(PercentEssentialsV1Marker = "percent/essentials@1")]#[derive(Default,Clone,PartialEq,Debug)]#[cfg_attr( feature = "datagen", derive(serde::Serialize, databake::Bake), databake(path = icu_dimension::provider),)]#[cfg_attr(feature = "serde", derive(serde::Deserialize))]pubstructPercentEssentialsV1<'data>{/// Percent format with plus signpubplus_pattern:Cow<'data,str>,/// Percent format with no signpubzero_pattern:Cow<'data,str>,/// Percent format with minus signpubminus_pattern:Cow<'data,str>,/// Index of the number placeholder within the plus patternpubplus_index:u8,/// Index of the number placeholder within the no-sign patternpubzero_index:u8,/// Index of the number placeholder within the minus patternpubminus_index:u8,}
We can make that a little bit more efficiently packed but I like to start with the clear and simple model.
Next, create provider/datagen/src/transform/cldr/decimal/percent.rs: this is where you will put your transform code. You need to have at least these impls:
Then, to plug it together, add your new data key in at least two places:
provider/datagen/src/registry.rs
pub const KEYS in experimental/dimension/src/provider.rs
With this, you should be able to run cargo make testdata at the project root and see the JSON data being generated. Once you get to this point, it is ready for a code review.
We do not currently have percentage formatting. We will need it for ECMA-402 compatibility.
We can do this in the scope of measurement unit formatting, but I think it would be useful to have a standalone percentage formatter since this is how it worked in previous versions of ECMA-402.
As a first step, we can make a data struct, probably in the
icu_dimension
crate.The text was updated successfully, but these errors were encountered: