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

use std::borrow::Cow;

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

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

fn main() {
    // Create some strings
    let static_str = "&str";
    let heap_allocated_string = String::from("String");
    let copy_on_write_str = Cow::from("Cow<str>");

    // Localize these strings, which just prints them.
    // This would mostly be useful for non-localizable content such as usernames or URLs
    println!(
        "Static string: {}",
        static_str.localize_for(&DEFAULT_LOCALE)
    );
    println!(
        "Heap allocated string: {}",
        heap_allocated_string.localize_for(&DEFAULT_LOCALE)
    );
    println!(
        "Copy on write string: {}",
        copy_on_write_str.localize_for(&DEFAULT_LOCALE)
    );
}