mod default;
#[cfg(feature = "locale_cs_CZ")]
mod cs_cz;
#[cfg(feature = "locale_de_AT")]
mod de_at;
#[cfg(feature = "locale_en_US")]
mod en_us;
use crate::HashMap;
use crate::{
ValueFormatBoolean, ValueFormatCurrency, ValueFormatDateTime, ValueFormatNumber,
ValueFormatPercentage, ValueFormatTimeDuration,
};
use icu_locale_core::Locale;
use lazy_static::lazy_static;
#[allow(dead_code)]
pub(crate) trait LocalizedValueFormat: Sync {
fn locale(&self) -> Locale;
fn boolean_format(&self) -> ValueFormatBoolean;
fn number_format(&self) -> ValueFormatNumber;
fn percentage_format(&self) -> ValueFormatPercentage;
fn currency_format(&self) -> ValueFormatCurrency;
fn date_format(&self) -> ValueFormatDateTime;
fn datetime_format(&self) -> ValueFormatDateTime;
fn time_of_day_format(&self) -> ValueFormatDateTime;
fn time_interval_format(&self) -> ValueFormatTimeDuration;
}
lazy_static! {
static ref LOCALE_DATA: HashMap<Locale, &'static dyn LocalizedValueFormat> = {
#[allow(unused_mut)]
let mut lm: HashMap<Locale, &'static dyn LocalizedValueFormat> = HashMap::new();
lm.insert(icu_locale_core::locale!("en"), &default::LOCALE_DEFAULT);
#[cfg(feature = "locale_cs_CZ")]
{
lm.insert(icu_locale_core::locale!("cs-CZ"), &cs_cz::LOCALE_CS_CZ);
}
#[cfg(feature = "locale_de_AT")]
{
lm.insert(icu_locale_core::locale!("de-AT"), &de_at::LOCALE_DE_AT);
}
#[cfg(feature = "locale_en_US")]
{
lm.insert(icu_locale_core::locale!("en-US"), &en_us::LOCALE_EN_US);
}
lm
};
}
pub(crate) fn localized_format(locale: Locale) -> Option<&'static dyn LocalizedValueFormat> {
LOCALE_DATA.get(&locale).copied()
}