standard-error 0.1.9

simplifies returning meaningful errors for axum services
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::cell::RefCell;
use std::env;

thread_local! {
    static LOCALE: RefCell<String> = RefCell::new(env::var("DEFAULT_LOCALE").unwrap_or("en_US".to_string()));
}

pub fn set_current_locale(locale: &str) {
    LOCALE.with(|s| {
        *s.borrow_mut() = locale.to_string();
    })
}

pub fn get_current_locale() -> String {
    LOCALE.with(|s| s.borrow().clone())
}