Function sys_locale::get_locale

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

Returns the active locale for the system or application.

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);
Examples found in repository?
examples/get_locale.rs (line 8)
7
8
9
10
11
fn main() {
    let locale = get_locale().unwrap_or_else(|| String::from("en-US"));

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