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

use icu_locale::locale;
use l10n_embed::list::{AndList, OrList, UnitList};
use l10n_embed::{Context, Localize};

fn main() {
    let items = vec!["item 1", "item 2", "item 3", "item 4"];

    // Create some lists of different lengths
    let and_list = AndList::new(items.clone());
    let or_list = OrList::new(items.clone());
    let unit_list = UnitList::new(items.clone());

    // Localize these lists
    let lists: [(&str, Box<dyn Localize>); 3] = [
        ("And list", Box::new(and_list)),
        ("Or list", Box::new(or_list)),
        ("Unit list", Box::new(unit_list)),
    ];

    let context = Context::new(locale!("en-US"), true);
    let mut buffer = String::new();

    for (name, list) in lists {
        buffer.clear();
        list.localize(&context, &mut buffer);

        println!("{name}: {buffer}");
    }
}