sys_locale

Function get_locales

Source
pub fn get_locales() -> impl Iterator<Item = String>
Expand description

Returns the preferred locales for the system or application, in descending order of preference.

§Returns

Returns an Iterator with any number of BCP 47 language tags inside.
If no locale preferences could be obtained, the iterator will be empty.

§Example

use sys_locale::get_locales;

let mut  locales = get_locales();

println!("The most preferred locale is {}", locales.next().unwrap_or("en-US".to_string()));
println!("The least preferred locale is {}", locales.last().unwrap_or("en-US".to_string()));