standard_error/locale.rs
1use std::cell::RefCell;
2use std::env;
3
4thread_local! {
5 static LOCALE: RefCell<String> = RefCell::new(env::var("DEFAULT_LOCALE").unwrap_or("en_US".to_string()));
6}
7
8pub fn set_current_locale(locale: &str) {
9 LOCALE.with(|s| {
10 *s.borrow_mut() = locale.to_string();
11 })
12}
13
14pub fn get_current_locale() -> String {
15 LOCALE.with(|s| s.borrow().clone())
16}