From d16bc14ffce7be3a48336eb286f4cc2e572e7866 Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 5 Dec 2022 00:29:51 -0600 Subject: [PATCH] add in locale-maxima --- Cargo.lock | 9 +++++++- Cargo.toml | 1 + libraries/locale-maxima/Cargo.toml | 9 ++++++++ libraries/locale-maxima/src/lib.rs | 33 ++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 libraries/locale-maxima/Cargo.toml create mode 100644 libraries/locale-maxima/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 96a51b8..7d09749 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,13 @@ dependencies = [ "table", ] +[[package]] +name = "locale-maxima" +version = "0.1.0" +dependencies = [ + "versioning", +] + [[package]] name = "log" version = "0.4.17" @@ -318,7 +325,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "versioning" -version = "0.1.2" +version = "0.1.3" dependencies = [ "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 04df00c..7ad4d9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "libraries/able_graphics_library", "libraries/clparse", + "libraries/locale-maxima", "libraries/tar", "libraries/trash_manifest", "libraries/versioning", diff --git a/libraries/locale-maxima/Cargo.toml b/libraries/locale-maxima/Cargo.toml new file mode 100644 index 0000000..d5d2fcc --- /dev/null +++ b/libraries/locale-maxima/Cargo.toml @@ -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" } diff --git a/libraries/locale-maxima/src/lib.rs b/libraries/locale-maxima/src/lib.rs new file mode 100644 index 0000000..2fd3227 --- /dev/null +++ b/libraries/locale-maxima/src/lib.rs @@ -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, +} +impl TranslationFile { + pub fn new() -> Self { + panic!("Translations are not yet supported"); + } + + pub fn translate(&self, key: &str) -> Result { + 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, +}