WIP: Locale strings

This commit is contained in:
2023-08-29 16:32:37 +02:00
parent 029a965860
commit 9cda8859da
14 changed files with 214 additions and 78 deletions

View File

@@ -32,12 +32,12 @@ async def command_checkout(app: PyroClient, message: Message):
row_width=1, resize_keyboard=True, one_time_keyboard=True
)
keyboard_delete.add(
ReplyButton("Yes, I want to delete it"),
ReplyButton("No, I don't want to delete it"),
ReplyButton(app._("delete_yes", "buttons", locale=user.locale)),
ReplyButton(app._("delete_no", "buttons", locale=user.locale)),
)
await message.reply_text(
"Here's pretty much all the data bot has. Please, use these buttons to choose whether you want to delete your data from the bot.",
app._("checkout", "messages", locale=user.locale),
reply_markup=keyboard_delete,
)
@@ -46,25 +46,25 @@ async def command_checkout(app: PyroClient, message: Message):
if answer_delete is None or answer_delete.text == "/cancel":
await message.reply_text(
"Cancelled.",
app._("cancelled", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
if answer_delete.text not in [
"Yes, I want to delete it",
"No, I don't want to delete it",
]:
if answer_delete.text not in app._(
"delete_yes", "buttons", locale=user.locale
) + app._("delete_no", "buttons", locale=user.locale):
await answer_delete.reply_text(
"Invalid answer provided. Use /cancel if you want to cancel this operation."
app._("selection_invalid", "messages", locale=user.locale).format(
cancel_notice=app._("cancel", "messages", locale=user.locale)
)
)
continue
if answer_delete.text in [
"No, I don't want to delete it",
]:
if answer_delete.text in app._("delete_no", "buttons", locale=user.locale):
await answer_delete.reply_text(
"Alright, cancelled.", reply_markup=ReplyKeyboardRemove()
app._("cancelled", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
@@ -74,10 +74,12 @@ async def command_checkout(app: PyroClient, message: Message):
keyboard_confirm = ReplyKeyboard(
row_width=1, resize_keyboard=True, one_time_keyboard=True
)
keyboard_confirm.add(ReplyButton("I agree and want to proceed"))
keyboard_confirm.add(
ReplyButton(app._("delete_confirm", "buttons", locale=user.locale))
)
await message.reply_text(
"Alright. Please, confirm that you want to delete your data from the bot.\n\nFollowing data will be deleted:\nSelected location, preferred language of the messages, notifications time and your notifications offset.",
app._("checkout_deletion", "messages", locale=user.locale),
reply_markup=keyboard_confirm,
)
@@ -86,14 +88,16 @@ async def command_checkout(app: PyroClient, message: Message):
if answer_confirm is None or answer_confirm.text == "/cancel":
await message.reply_text(
"Cancelled.",
app._("cancelled", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
if answer_confirm.text not in ["I agree and want to proceed"]:
if answer_confirm.text not in app.in_all_locales("delete_confirm", "buttons"):
await answer_confirm.reply_text(
"Invalid answer provided. Use /cancel if you want to cancel this operation."
app._("selection_invalid", "messages", locale=user.locale).format(
cancel_notice=app._("cancel", "messages", locale=user.locale)
)
)
continue
@@ -101,6 +105,6 @@ async def command_checkout(app: PyroClient, message: Message):
await user.delete()
await answer_confirm.reply_text(
"Your data has been deleted. If you want to start using this bot again, please use /setup command. Otherwise delete/block the bot and do not interact with it anymore.",
app._("checkout_deleted", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)