Skip to content

Commit

Permalink
Add Dates to FsDataProviderExport
Browse files Browse the repository at this point in the history
  • Loading branch information
zbraniecki committed Sep 22, 2020
1 parent 7bef1db commit 029a5df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/fs-data-provider/src/bin/icu4x-cldr-export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ fn main() -> Result<(), Error> {
)
.takes_value(true),
)
.arg(
Arg::with_name("CLDR_DATES")
.long("cldr-dates")
.value_name("PATH")
.help(
"Path to cldr-dates JSON: \
https://github.com/unicode-cldr/cldr-dates",
)
.takes_value(true),
)
.arg(
Arg::with_name("KEY")
.short("k")
Expand Down Expand Up @@ -153,6 +163,7 @@ fn main() -> Result<(), Error> {
let keys = [
icu_data_key!(plurals: cardinal@1),
icu_data_key!(plurals: ordinal@1),
icu_data_key!(dates: gregory@1),
];

let output_path = PathBuf::from(
Expand All @@ -167,6 +178,10 @@ fn main() -> Result<(), Error> {
cldr_paths.cldr_core = Ok(path.into());
}

if let Some(path) = matches.value_of("CLDR_DATES") {
cldr_paths.cldr_dates = Ok(path.into());
}

let provider = CldrJsonDataProvider::new(&cldr_paths);

let mut options = serializers::JsonSerializerOptions::default();
Expand Down
12 changes: 12 additions & 0 deletions components/fs-data-provider/src/fs_data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ impl DataProvider<'_> for FsDataProvider {
}
.with_owned_payload(obj);
Ok(response)
} else if req.data_key.category == DataCategory::Dates {
// TODO: Pick deserializer based on manifest
let obj: structs::dates::gregory::DatesV1 = match serde_json::from_reader(reader) {
Ok(obj) => obj,
Err(err) => return Err(Error::ResourceError(Box::new(err))),
};
let response = DataResponseBuilder {
// TODO: Return the actual locale when fallbacks are implemented.
data_langid: req.data_entry.langid.clone(),
}
.with_owned_payload(obj);
Ok(response)
} else {
panic!("Don't know how to parse this data key, but it is on the filesystem");
}
Expand Down

0 comments on commit 029a5df

Please sign in to comment.