aboutsummaryrefslogtreecommitdiff
path: root/azalea-language/src/lib.rs
blob: 81c3cee2b2dc6bdf4d0f4756ed8853811c728bf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Translate Minecraft strings from their id.

use once_cell::sync::Lazy;
use std::collections::HashMap;

pub static STORAGE: Lazy<HashMap<String, String>> =
    Lazy::new(|| serde_json::from_str(include_str!("en_us.json")).unwrap());

pub fn get(key: &str) -> Option<&str> {
    STORAGE.get(key).map(|s| s.as_str())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_get() {
        assert_eq!(get("translation.test.none"), Some("Hello, world!"));
    }
}