aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/locale.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/locale.rs b/src/locale.rs
index 1bd190b..7d4b940 100644
--- a/src/locale.rs
+++ b/src/locale.rs
@@ -33,8 +33,20 @@ impl Locale {
}
}
+fn from_locale_str(l: &str) -> &'static Locale {
+ match &l[0..2] {
+ "nb" => &NB,
+ _ => &EN, // Return default EN locale if we don't have a locale for the given str.
+ }
+}
+
pub fn get() -> &'static Locale {
- &EN
+ match std::env::var("LC_TIME") {
+ Ok(l) => {
+ from_locale_str(&l)
+ },
+ Err(_) => &EN, // Return default EN locale if no locale is defined
+ }
}
pub const EN: Locale = Locale {