bcmyers / num-format

A Rust crate for producing string representations of numbers, formatted according to international standards
Apache License 2.0
123 stars 22 forks source link

Locale::from_name on de-DE or en-US #45

Open GunnarBernsteinHH opened 8 months ago

GunnarBernsteinHH commented 8 months ago

I am not sure if this is intended behavior.

When I try to use the locale, I am idendifying it automatically like

let current_locale = sys_locale::get_locale().unwrap_or_else(|| String::from("en-US"));

This produces de-DE or en-US.

But:

    let a = Locale::from_name("de-CH"); // ok
    let b = Locale::from_name("de-DE"); // not found, here only 'de' can be used
    let c = Locale::from_name("en-US"); // not found, here only 'en' can be used
    let d = Locale::from_name("en-HK"); // ok

It would be nice if the crate would automatically fallback to the 2 digit allowed locale.