diff --git a/provider/datagen/src/transform/cldr/cldr_serde/displaynames/variant.rs b/provider/datagen/src/transform/cldr/cldr_serde/displaynames/variant.rs index 28a538a9681..f143c16f201 100644 --- a/provider/datagen/src/transform/cldr/cldr_serde/displaynames/variant.rs +++ b/provider/datagen/src/transform/cldr/cldr_serde/displaynames/variant.rs @@ -10,9 +10,19 @@ use serde::Deserialize; use std::collections::HashMap; +#[derive(PartialEq, Debug, Deserialize)] +#[serde(untagged)] +pub enum StringOrEmptyMap { + String(String), + // CLDR-JSON 44 contains some empty maps in place of strings in the + // variants table. This might be a bug. Track progress: + // + Empty {}, +} + #[derive(PartialEq, Debug, Deserialize)] pub struct Variants { - pub variants: HashMap, + pub variants: HashMap, } #[derive(PartialEq, Debug, Deserialize)] diff --git a/provider/datagen/src/transform/cldr/displaynames/variant.rs b/provider/datagen/src/transform/cldr/displaynames/variant.rs index 1adf22ae210..38adb165a1d 100644 --- a/provider/datagen/src/transform/cldr/displaynames/variant.rs +++ b/provider/datagen/src/transform/cldr/displaynames/variant.rs @@ -63,9 +63,11 @@ impl TryFrom<&cldr_serde::displaynames::variant::Resource> for VariantDisplayNam fn try_from(other: &cldr_serde::displaynames::variant::Resource) -> Result { let mut names = BTreeMap::new(); for entry in other.main.value.localedisplaynames.variants.iter() { - // TODO: Support alt variants for variant display names. - if !entry.0.contains(ALT_SUBSTRING) { - names.insert(Variant::from_str(entry.0)?.into_tinystr(), entry.1.as_str()); + if let cldr_serde::displaynames::variant::StringOrEmptyMap::String(variant) = entry.1 { + // TODO: Support alt variants for variant display names. + if !entry.0.contains(ALT_SUBSTRING) { + names.insert(Variant::from_str(entry.0)?.into_tinystr(), variant.as_str()); + } } } Ok(Self {