From 82cadd97279111f8366051e4b6c336cf35950106 Mon Sep 17 00:00:00 2001 From: Claas Augner <caugner@mozilla.com> Date: Wed, 18 Sep 2024 18:18:26 +0200 Subject: [PATCH 1/3] feat(locale): add German --- crates/rari-md/src/node_card.rs | 3 +++ crates/rari-types/src/locale.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/crates/rari-md/src/node_card.rs b/crates/rari-md/src/node_card.rs index e9ff7b69..2954d236 100644 --- a/crates/rari-md/src/node_card.rs +++ b/crates/rari-md/src/node_card.rs @@ -10,6 +10,9 @@ pub enum NoteCard { impl NoteCard { pub fn prefix_for_locale(&self, locale: Locale) -> &str { match (self, locale) { + (Self::Callout, Locale::De) => "Hinweis", + (Self::Warning, Locale::De) => "Warnung", + (Self::Note, Locale::De) => "Notiz", (Self::Callout, Locale::EnUs) => "Callout:", (Self::Warning, Locale::EnUs) => "Warning:", (Self::Note, Locale::EnUs) => "Note:", diff --git a/crates/rari-types/src/locale.rs b/crates/rari-types/src/locale.rs index d11fd841..baacbbaa 100644 --- a/crates/rari-types/src/locale.rs +++ b/crates/rari-types/src/locale.rs @@ -10,6 +10,8 @@ use crate::globals::content_translated_root; #[derive(PartialEq, Debug, Clone, Copy, Deserialize, Serialize, Default, PartialOrd, Eq, Ord)] pub enum Native { #[default] + #[serde(rename = "Deutsch")] + De, #[serde(rename = "English (US)")] EnUS, #[serde(rename = r#"EspaƱol"#)] @@ -33,6 +35,7 @@ pub enum Native { impl From<Locale> for Native { fn from(value: Locale) -> Self { match value { + Locale::De => Self::De, Locale::EnUs => Self::EnUS, Locale::Es => Self::Es, Locale::Fr => Self::Fr, @@ -61,6 +64,8 @@ pub enum LocaleError { )] pub enum Locale { #[default] + #[serde(rename = "de")] + De, #[serde(rename = "en-US")] EnUs, #[serde(rename = "es")] @@ -90,6 +95,7 @@ impl Display for Locale { impl Locale { pub const fn as_url_str(&self) -> &str { match *self { + Self::De => "de", Self::EnUs => "en-US", Self::Es => "es", Self::Fr => "fr", @@ -135,6 +141,7 @@ impl FromStr for Locale { fn from_str(s: &str) -> Result<Self, Self::Err> { match s { + "de" => Ok(Self::De), "en-US" | "en-us" => Ok(Self::EnUs), "es" => Ok(Self::Es), "fr" => Ok(Self::Fr), From 0387a14598d774bb029b1e2e813fabc6e61a1dd1 Mon Sep 17 00:00:00 2001 From: Claas Augner <caugner@mozilla.com> Date: Wed, 18 Sep 2024 19:15:36 +0200 Subject: [PATCH 2/3] fixup! feat(locale): add German --- crates/rari-types/src/locale.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rari-types/src/locale.rs b/crates/rari-types/src/locale.rs index baacbbaa..062a9023 100644 --- a/crates/rari-types/src/locale.rs +++ b/crates/rari-types/src/locale.rs @@ -120,6 +120,7 @@ impl Locale { pub fn all() -> &'static [Self] { if content_translated_root().is_some() { &[ + Self::De, Self::EnUs, Self::Es, Self::Fr, From 87e0700add12ce0f0e595309c7a53e98ac974c6d Mon Sep 17 00:00:00 2001 From: Claas Augner <495429+caugner@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:09:25 +0200 Subject: [PATCH 3/3] Apply suggestions from code review --- crates/rari-md/src/node_card.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/rari-md/src/node_card.rs b/crates/rari-md/src/node_card.rs index 2954d236..6c95fc5f 100644 --- a/crates/rari-md/src/node_card.rs +++ b/crates/rari-md/src/node_card.rs @@ -10,9 +10,9 @@ pub enum NoteCard { impl NoteCard { pub fn prefix_for_locale(&self, locale: Locale) -> &str { match (self, locale) { - (Self::Callout, Locale::De) => "Hinweis", - (Self::Warning, Locale::De) => "Warnung", - (Self::Note, Locale::De) => "Notiz", + (Self::Callout, Locale::De) => "Aufruf:", + (Self::Warning, Locale::De) => "Warnung:", + (Self::Note, Locale::De) => "Hinweis:", (Self::Callout, Locale::EnUs) => "Callout:", (Self::Warning, Locale::EnUs) => "Warning:", (Self::Note, Locale::EnUs) => "Note:",