Add a calendar to schedule a recipe to a chosen date (WIP)
This commit is contained in:
parent
d9449de02b
commit
9d3f9e9c60
15 changed files with 441 additions and 62 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fs::File, sync::LazyLock};
|
||||
use std::{borrow::Borrow, fs::File, sync::LazyLock};
|
||||
|
||||
use ron::de::from_reader;
|
||||
use serde::Deserialize;
|
||||
|
|
@ -114,6 +114,27 @@ pub enum Sentence {
|
|||
RecipeOneServing,
|
||||
RecipeSomeServings,
|
||||
RecipeEstimatedTimeMinAbbreviation,
|
||||
|
||||
// Calendar.
|
||||
CalendarMondayAbbreviation,
|
||||
CalendarTuesdayAbbreviation,
|
||||
CalendarWednesdayAbbreviation,
|
||||
CalendarThursdayAbbreviation,
|
||||
CalendarFridayAbbreviation,
|
||||
CalendarSaturdayAbbreviation,
|
||||
CalendarSundayAbbreviation,
|
||||
CalendarJanuary,
|
||||
CalendarFebruary,
|
||||
CalendarMarch,
|
||||
CalendarApril,
|
||||
CalendarMay,
|
||||
CalendarJune,
|
||||
CalendarJuly,
|
||||
CalendarAugust,
|
||||
CalendarSeptember,
|
||||
CalendarOctober,
|
||||
CalendarNovember,
|
||||
CalendarDecember,
|
||||
}
|
||||
|
||||
pub const DEFAULT_LANGUAGE_CODE: &str = "en";
|
||||
|
|
@ -131,7 +152,10 @@ impl Tr {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn t(&self, sentence: Sentence) -> &'static str {
|
||||
pub fn t<T>(&self, sentence: T) -> &'static str
|
||||
where
|
||||
T: Borrow<Sentence>,
|
||||
{
|
||||
self.lang.get(sentence)
|
||||
}
|
||||
|
||||
|
|
@ -196,10 +220,15 @@ impl Language {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get(&'static self, sentence: Sentence) -> &'static str {
|
||||
pub fn get<T>(&'static self, sentence: T) -> &'static str
|
||||
where
|
||||
T: Borrow<Sentence>,
|
||||
{
|
||||
let sentence_cloned: Sentence = sentence.borrow().clone();
|
||||
|
||||
let text: &str = self
|
||||
.translation
|
||||
.get(sentence.clone() as usize)
|
||||
.get(sentence_cloned as usize)
|
||||
.unwrap()
|
||||
.as_ref();
|
||||
if text.is_empty() && self.code != DEFAULT_LANGUAGE_CODE {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue