add in locale-maxima

This commit is contained in:
Able 2022-12-05 00:29:51 -06:00
parent c758d0aecb
commit d16bc14ffc
4 changed files with 51 additions and 1 deletions

9
Cargo.lock generated
View file

@ -136,6 +136,13 @@ dependencies = [
"table", "table",
] ]
[[package]]
name = "locale-maxima"
version = "0.1.0"
dependencies = [
"versioning",
]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.17" version = "0.4.17"
@ -318,7 +325,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "versioning" name = "versioning"
version = "0.1.2" version = "0.1.3"
dependencies = [ dependencies = [
"serde", "serde",
] ]

View file

@ -9,6 +9,7 @@ members = [
"libraries/able_graphics_library", "libraries/able_graphics_library",
"libraries/clparse", "libraries/clparse",
"libraries/locale-maxima",
"libraries/tar", "libraries/tar",
"libraries/trash_manifest", "libraries/trash_manifest",
"libraries/versioning", "libraries/versioning",

View file

@ -0,0 +1,9 @@
[package]
name = "locale-maxima"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
versioning = { path = "../versioning" }

View file

@ -0,0 +1,33 @@
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,
}