1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Locale capabilities for the crate.

use tr::tr;

/// Get the name of two-letter a locale.
///
/// Be aware that this only gives names for locales that are used in
/// this crate. Others will return the given locale.
pub fn locale_name(s: &str) -> String {
    match s {
        "de" => "German".to_string(),
        "en" => "English".to_string(),
        "ru" => "Russian".to_string(),
        "fr" => "French".to_string(),
        "es" => "Spanish".to_string(),
        "it" => "Italian".to_string(),
        "sk" => "Slovakian".to_string(),
        _ => s.to_string(),
    }
}

/// Get the name of two-letter a locale in the current UI locale.
///
/// Be aware that this only gives names for locales that are used in
/// this crate. Others will return the given locale.
pub fn locale_name_in_current_locale(s: &str) -> String {
    match s {
        "de" => tr!("German"),
        "en" => tr!("English"),
        "ru" => tr!("Russian"),
        "fr" => tr!("French"),
        "es" => tr!("Spanish"),
        "it" => tr!("Italian"),
        "sk" => tr!("Slovakian"),
        _ => s.to_string(),
    }
}