ableos_userland/libraries/locale-maxima/src/lib.rs
2022-12-05 00:29:51 -06:00

34 lines
805 B
Rust

use std::collections::HashMap;
use versioning::Version;
pub const VERSION: Version = Version::new(0, 1, 1);
pub struct Locale {
pub language: String,
pub region: String,
pub time_zone: String,
}
pub struct TranslationFile {
pub strings: HashMap<String, String>,
}
impl TranslationFile {
pub fn new() -> Self {
panic!("Translations are not yet supported");
}
pub fn translate(&self, key: &str) -> Result<String, TranslationError> {
let maybe_translated_string = self.strings.get(key);
use crate::TranslationError::*;
match maybe_translated_string {
Some(translated_string) => Ok(translated_string.to_string()),
None => Err(NoTranslationFound),
}
}
}
pub enum TranslationError {
NoTranslationFound,
}