Pull user visible messages from localization library

This commit is contained in:
2023-01-25 23:04:53 +01:00
parent ed9bd87ab5
commit f3136bd319
6 changed files with 266 additions and 10 deletions

View File

@@ -159,7 +159,11 @@ pub async fn fetch_and_announce_appointment(
let announcement = bot
.send_message(
ChatId(chat_info.id),
format!("Nächster Termin: {}, {}", weekday, date_str),
t!(
"messages.next_appointment",
weekday = weekday,
date = &date_str.to_string()
),
)
.await?;

View File

@@ -29,6 +29,11 @@ use tokio::time::sleep;
use crate::db::DbChat;
#[macro_use]
extern crate rust_i18n;
i18n!("locales");
#[derive(Deserialize, Debug)]
pub struct Config {
token: String,
@@ -152,16 +157,16 @@ async fn check_task(bot: &Throttle<Bot>, reminder_time: NaiveTime, db: &Database
if now >= appointment.start {
reminder = Some(Reminder {
time: appointment.start,
text: "Jetzt geht's weiter".into(),
text: t!("messages.starting_now"),
});
} else {
let reminder_date_time = now.date().and_time(reminder_time).unwrap();
if now >= reminder_date_time {
reminder = Some(Reminder {
time: reminder_date_time,
text: format!(
"Heute um {} Uhr geht's weiter",
appointment.start.format("%H:%M")
text: t!(
"messages.appointment_today",
start_time = &appointment.start.format("%H:%M").to_string()
),
})
}