sys_locale

Function get_locale

Source
pub fn get_locale() -> Option<String>
Expand description

Returns the most preferred locale for the system or application.

This is equivalent to get_locales().next() (the first entry).

§Returns

Returns [Some(String)] with a BCP 47 language tag inside.
If the locale couldn’t be obtained, None is returned instead.

§Example

use sys_locale::get_locale;

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

println!("The locale is {}", current_locale);