-
Notifications
You must be signed in to change notification settings - Fork 182
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
Update data model for non-gregorian calendars #1300
Conversation
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.
LGTM except for "gregorian" -> "gregory" when used as a string identifier
Ok(idx) => &self.data[idx].1.dates, | ||
Err(_) => return Err(DataError::MissingResourceOptions(req.clone())), | ||
}; | ||
let dates = self.0.dates_for(req)?; |
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.
Praise: I like the way you refactored this code
@@ -37,7 +37,7 @@ impl TryFrom<&dyn CldrPaths> for TimeZonesProvider { | |||
fn try_from(cldr_paths: &dyn CldrPaths) -> Result<Self, Self::Error> { | |||
let mut data = vec![]; | |||
|
|||
let path = cldr_paths.cldr_dates()?.join("main"); | |||
let path = cldr_paths.cldr_dates("gregorian")?.join("main"); |
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.
Question: Is there time zone data in other calendars, or is it always stored in the gregorian calendar data bundle?
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.
Not that I know of: https://github.com/unicode-cldr/cldr-cal-buddhist-full/tree/master/main/af
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.
(I linked to the wrong repo, but the point still stands when looking at the cldr-json repo)
let list: Vec<ResourceOptions> = self | ||
.data | ||
.iter() | ||
.flat_map(|(cal, map)| { |
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.
Note: This is the "magic" that informs the data exporter to loop over both variants and locales when putting together the data tree.
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.
Everything looks reasonable to me.
Progress on #1115
Previously, date data was stored as
gregory_symbols@1/en.json
(etc). We'd like to use the same data format for all of the calendars, so now data is stored undersymbols@1/gregorian/en.json
, with"gregorian"
being the variant. Datetime data now requires a variant referring to the calendar.Datetime formatting code has not been modified to support other calendars; it hardcodes
"gregorian"
instead. This will be updated in a future PR; this PR is just setting the stage for these changes.The full changes here are:
CldrPaths
supports yielding multiple calendars, though only gregorian is hooked up right now.CldrPaths
, sorted under variantsGREGORY_FOO_BAR
keys have been renamed to remove "gregory" from the namegregory
data struct module has been renamed tocalendar