Framework for embedding localizations into Rust types
//! Example showing how to localize fixed_decimal decimals

use fixed_decimal::Decimal;
use icu_locale::{Locale, locale};
use l10n_embed::Localize;

const DEFAULT_LOCALE: Locale = locale!("en-US");

fn main() -> Result<(), fixed_decimal::LimitError> {
    // Create some decimals
    let zero: i32 = 0;
    let five_million: u64 = 5_000_000;
    let zero_point_two: f64 = 0.2;
    let mut negative_two_point_five = Decimal::from(-25);
    negative_two_point_five.multiply_pow10(-1);

    // Localize those decimals into a human-readable number
    println!("Zero: {}", zero.localize_for(&DEFAULT_LOCALE));
    println!(
        "Five million: {}",
        five_million.localize_for(&DEFAULT_LOCALE)
    );
    println!(
        "Zero point two: {}",
        zero_point_two.localize_for(&DEFAULT_LOCALE)
    );
    println!(
        "Negative two point five: {}",
        negative_two_point_five.localize_for(&DEFAULT_LOCALE)
    );

    Ok(())
}