Skip to content

feat(locale): add German #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/rari-md/src/node_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
8 changes: 8 additions & 0 deletions crates/rari-types/src/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"#)]
Expand All @@ -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,
Expand Down Expand Up @@ -61,6 +64,8 @@ pub enum LocaleError {
)]
pub enum Locale {
#[default]
#[serde(rename = "de")]
De,
#[serde(rename = "en-US")]
EnUs,
#[serde(rename = "es")]
Expand Down Expand Up @@ -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",
Expand All @@ -114,6 +120,7 @@ impl Locale {
pub fn all() -> &'static [Self] {
if content_translated_root().is_some() {
&[
Self::De,
Self::EnUs,
Self::Es,
Self::Fr,
Expand All @@ -135,6 +142,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),
Expand Down