Skip to content
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

Enable english #526

Merged
merged 5 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,4 @@ packages:
version: "3.0.3"
sdks:
dart: ">=3.3.4 <4.0.0"
flutter: ">=3.16.0"
flutter: ">=3.18.0-18.0.pre.54"
2 changes: 1 addition & 1 deletion app/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ crate-type = ["cdylib", "staticlib"]
[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
first_aid_bot_core = { path = "../../core" }
flutter_rust_bridge = "=2.0.0-dev.34"
flutter_rust_bridge = "=2.0.0-dev.32"
anyhow = { workspace = true }
4 changes: 2 additions & 2 deletions bot/src/bot/dialogue/logic/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ async fn broadcast_if_confirmed(
async fn ask_to_confirm(bot: &FABot, id: ChatId, text: &str, dialogue: &FADialogue) -> Result<()> {
bot.send_message(id, "Your message is:").await?;
let vec = vec![MSG_CONFIRM];
let keyboard = make_keyboard(&vec, Lang::Ua, 42, true);
let keyboard = make_keyboard(&vec, Lang::En, 42, true);
bot.send_message(id, text).reply_markup(keyboard).await?;
let message = Some(text.to_string());
dialogue.update(State::Broadcast { message }).await?;
Ok(())
}

async fn wait_for_message(bot: &FABot, id: ChatId) -> Result<()> {
let kbd = make_keyboard(&Vec::new(), Lang::Ua, 42, true);
let kbd = make_keyboard(&Vec::new(), Lang::En, 42, true);
bot.send_message(id, MSG_REQUEST).reply_markup(kbd).await?;
Ok(())
}
63 changes: 37 additions & 26 deletions core/src/model/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@ use std::fmt::Display;

#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
pub enum Lang {
// Ua,
#[default]
Ua,
/* En,
Ru, */
En,
// Ru
}

impl Lang {
// https://github.com/rust-lang/rfcs/issues/284
pub fn iter() -> impl Iterator<Item = Self> {
[Lang::Ua /* En, Ru */].into_iter()
// [Lang::Ua].into_iter()
[Lang::En].into_iter()
}
pub const fn details(self) -> LangDetails {
match self {
Lang::Ua => UA_LD,
/* En => EN_LD,
Ru => RU_LD, */
// Lang::Ua => UA_LD,
Lang::En => EN_LD,
// Lang::Ru => RU_LD,
}
}
pub fn name(self) -> String {
Expand Down Expand Up @@ -69,33 +70,43 @@ pub struct LangDetails {
pub broadcast: &'static str,
}

const UA_LD: LangDetails = LangDetails {
name: "Ukrainian",
button_lang: "Українська",
button_back: "◀️ Повернутись",
button_home: "◀️ На початок",
// const UA_LD: LangDetails = LangDetails {
// name: "Ukrainian",
// button_lang: "Українська",
// button_back: "◀️ Повернутись",
// button_home: "◀️ На початок",
// error: concatcp!(
// "Сталась помилка :( Перезапустіть бота (/start), і якщо це не допоможе, будь ласка, повідомте про це у ",
// HELP_CHAT_URL
// ),
// error_due_to_update: concatcp!(
// "Схоже, що бота було оновлено. Повертаюсь на початок. Якщо бот далі не працює, будь ласка, повідомте про це у ",
// HELP_CHAT_URL
// ),
// use_buttons_text: "Використайте кнопки, або перезавантажте бота \\(/start\\)",
// // TODO: Change it <26-06-22, astadnik> //
// greeting: "Що трапилось?",
// broadcast: "Транслювати",
// };

const EN_LD: LangDetails = LangDetails {
name: "English",
button_lang: "English",
button_back: "◀️ Back",
button_home: "◀️ Home",
error: concatcp!(
"Сталась помилка :( Перезапустіть бота (/start), і якщо це не допоможе, будь ласка, повідомте про це у ",
"An error occurred :( Restart the bot (/start), and if that doesn't help, please report it in ",
HELP_CHAT_URL
),
error_due_to_update: concatcp!(
"Схоже, що бота було оновлено. Повертаюсь на початок. Якщо бот далі не працює, будь ласка, повідомте про це у ",
"It seems that the bot has been updated. Returning to the beginning. If the bot still doesn't work, please report it in ",
HELP_CHAT_URL
),
use_buttons_text: "Використайте кнопки, або перезавантажте бота \\(/start\\)",
// TODO: Change it <26-06-22, astadnik> //
greeting: "Що трапилось?",
broadcast: "Транслювати",
use_buttons_text: "Use buttons, or restart bot if something is wrong (/start)",
greeting: "What happened?",
broadcast: "Broadcast",
};

// const EN_LD: LangDetails = LangDetails {
// name: "English",
// button_lang_name: "English",
// error: "An error occured, please tell us about it at " + HELP_CHAT_URL,
// use_buttons_text: "Use buttons, or restart bot i\f something is wrong (/start)",
// greeting: "What happened?",
// };

// const RU_LD: LangDetails = LangDetails {
// name: "Russian",
// button_lang_name: "Русский",
Expand Down
Loading