db: rename lang codes

This commit is contained in:
Dmitriy Pleshevskiy 2022-05-13 19:42:43 +03:00
parent 1bc6689104
commit 63a414a7bb
10 changed files with 70 additions and 70 deletions

View File

@ -42,13 +42,13 @@ impl From<(&db::data::Ingredient, Lang)> for Ingredient {
fn from((db, lang): (&db::data::Ingredient, Lang)) -> Self {
let tr = &db.translates;
let name = match lang {
Lang::Rus => tr.ru,
Lang::Eng => tr.en.unwrap_or(tr.ru),
Lang::Rus => tr.rus,
Lang::Eng => tr.eng.unwrap_or(tr.rus),
};
Self {
key: db.key.to_string(),
lang: if name == tr.ru { Lang::Rus } else { lang },
lang: if name == tr.rus { Lang::Rus } else { lang },
name: name.to_string(),
}
}

View File

@ -71,29 +71,29 @@ impl InMemoryIngredientRepo {
db::data::Ingredient {
key: "apple",
translates: db::data::IngredientTranslate {
ru: "Яблоко",
en: Some("Apple"),
rus: "Яблоко",
eng: Some("Apple"),
},
},
db::data::Ingredient {
key: "orange",
translates: db::data::IngredientTranslate {
ru: "Апельсин",
en: None,
rus: "Апельсин",
eng: None,
},
},
db::data::Ingredient {
key: "salt",
translates: db::data::IngredientTranslate {
ru: "Соль",
en: Some("Salt"),
rus: "Соль",
eng: Some("Salt"),
},
},
db::data::Ingredient {
key: "sugar",
translates: db::data::IngredientTranslate {
ru: "Сахар",
en: None,
rus: "Сахар",
eng: None,
},
},
],

View File

@ -33,8 +33,8 @@ pub struct Ingredient {
#[derive(Debug)]
pub struct IngredientTranslate {
pub ru: &'static str,
pub en: Option<&'static str>,
pub rus: &'static str,
pub eng: Option<&'static str>,
}
#[derive(Debug)]
@ -61,8 +61,8 @@ pub enum RecipeIngredientMeasure {
#[derive(Debug)]
pub struct RecipeTranslates {
ru: RecipeTranslate,
en: Option<RecipeTranslate>,
rus: RecipeTranslate,
eng: Option<RecipeTranslate>,
}
#[derive(Debug)]
@ -93,8 +93,8 @@ pub struct Ingredient {
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct IngredientTranslate {
ru: String,
en: Option<String>,
rus: String,
eng: Option<String>,
}
#[derive(Deserialize)]
@ -150,8 +150,8 @@ pub enum RecipeIngredientMeasure {
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct RecipeTranslates {
ru: RecipeTranslate,
en: Option<RecipeTranslate>,
rus: RecipeTranslate,
eng: Option<RecipeTranslate>,
}
#[derive(Deserialize)]

View File

@ -2,19 +2,19 @@
key = "apple"
measure = "kg"
[ingredients.translates]
ru = "яблоко"
en = "apple"
rus = "яблоко"
eng = "apple"
[[ingredients]]
key = "banana"
measure = "kg"
[ingredients.translates]
ru = "банан"
en = "banana"
rus = "банан"
eng = "banana"
[[ingredients]]
key = "orange"
measure = "kg"
[ingredients.translates]
ru = "апельсин"
en = "orange"
rus = "апельсин"
eng = "orange"

View File

@ -3,6 +3,6 @@
key = "water"
measure = "ml"
[ingredients.translates]
ru = "вода"
en = "water"
rus = "вода"
eng = "water"

View File

@ -2,20 +2,20 @@
key = "wheat_flour"
measure = "g"
[ingredients.translates]
ru = "пшеничная мука"
en = "wheat flour"
rus = "пшеничная мука"
eng = "wheat flour"
[[ingredients]]
key = "olive_oil"
measure = "ml"
[ingredients.translates]
ru = "оливковое масло"
en = "olive oil"
rus = "оливковое масло"
eng = "olive oil"
[[ingredients]]
key = "dry_yeast"
measure = "g"
[ingredients.translates]
ru = "сухие дрожжи"
en = "dry yeast"
rus = "сухие дрожжи"
eng = "dry yeast"

View File

@ -3,13 +3,13 @@
key = "salt"
measure = "g"
[ingredients.translates]
ru = "соль"
en = "salt"
rus = "соль"
eng = "salt"
[[ingredients]]
key = "sugar"
measure = "g"
[ingredients.translates]
ru = "сахар"
en = "sugar"
rus = "сахар"
eng = "sugar"

View File

@ -2,13 +2,13 @@
key = "carrot"
measure = "kg"
[ingredients.translates]
ru = "морковь"
en = "carrot"
rus = "морковь"
eng = "carrot"
[[ingredients]]
key = "potato"
measure = "kg"
[ingredients.translates]
ru = "картофель"
en = "potato"
rus = "картофель"
eng = "potato"

View File

@ -12,7 +12,7 @@ ingredients = [
steps = 7
[recipes.translates.ru]
[recipes.translates.rus]
name = "Тонкая хрустящая основа для пиццы"
instructions = [
"Растворить дрожжи в воде, подогретой до температуры тела.",

View File

@ -8,8 +8,8 @@ pub struct Ingredient {
#[derive(Debug)]
pub struct IngredientTranslate {
pub ru: &'static str,
pub en: Option<&'static str>,
pub rus: &'static str,
pub eng: Option<&'static str>,
}
#[derive(Debug)]
@ -36,8 +36,8 @@ pub enum RecipeIngredientMeasure {
#[derive(Debug)]
pub struct RecipeTranslates {
ru: RecipeTranslate,
en: Option<RecipeTranslate>,
rus: RecipeTranslate,
eng: Option<RecipeTranslate>,
}
#[derive(Debug)]
@ -50,8 +50,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "water",
translates: IngredientTranslate {
ru: "вода",
en: Some(
rus: "вода",
eng: Some(
"water",
),
},
@ -59,8 +59,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "carrot",
translates: IngredientTranslate {
ru: "морковь",
en: Some(
rus: "морковь",
eng: Some(
"carrot",
),
},
@ -68,8 +68,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "potato",
translates: IngredientTranslate {
ru: "картофель",
en: Some(
rus: "картофель",
eng: Some(
"potato",
),
},
@ -77,8 +77,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "wheat_flour",
translates: IngredientTranslate {
ru: "пшеничная мука",
en: Some(
rus: "пшеничная мука",
eng: Some(
"wheat flour",
),
},
@ -86,8 +86,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "olive_oil",
translates: IngredientTranslate {
ru: "оливковое масло",
en: Some(
rus: "оливковое масло",
eng: Some(
"olive oil",
),
},
@ -95,8 +95,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "dry_yeast",
translates: IngredientTranslate {
ru: "сухие дрожжи",
en: Some(
rus: "сухие дрожжи",
eng: Some(
"dry yeast",
),
},
@ -104,8 +104,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "apple",
translates: IngredientTranslate {
ru: "яблоко",
en: Some(
rus: "яблоко",
eng: Some(
"apple",
),
},
@ -113,8 +113,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "banana",
translates: IngredientTranslate {
ru: "банан",
en: Some(
rus: "банан",
eng: Some(
"banana",
),
},
@ -122,8 +122,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "orange",
translates: IngredientTranslate {
ru: "апельсин",
en: Some(
rus: "апельсин",
eng: Some(
"orange",
),
},
@ -131,8 +131,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "salt",
translates: IngredientTranslate {
ru: "соль",
en: Some(
rus: "соль",
eng: Some(
"salt",
),
},
@ -140,8 +140,8 @@ pub const INGREDIENTS: [Ingredient; 11] = [
Ingredient {
key: "sugar",
translates: IngredientTranslate {
ru: "сахар",
en: Some(
rus: "сахар",
eng: Some(
"sugar",
),
},
@ -180,7 +180,7 @@ pub static ref RECIPES: [Recipe; 1] = [
},
],
translates: RecipeTranslates {
ru: RecipeTranslate {
rus: RecipeTranslate {
name: "Тонкая хрустящая основа для пиццы",
instructions: vec![
"Растворить дрожжи в воде, подогретой до температуры тела.",
@ -192,7 +192,7 @@ pub static ref RECIPES: [Recipe; 1] = [
"Теперь на основу можно выкладывать начинку на ваш вкус и запекать до момента, когда сыр растает.",
],
},
en: None,
eng: None,
},
},
];