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

@@ -27,21 +27,27 @@ async def command_start(app: PyroClient, message: Message):
location = await app.get_location(int(join_code))
except ValueError:
await message.reply_text(
"🚫 You have provided the location but it does not seem to be a valid one. Please, use the command /setup to manually configure the location."
app._("start_code_invalid", "messages", locale=user.locale)
)
return
keyboard = ReplyKeyboardMarkup(
[
[KeyboardButton("Yes, I want to use it")],
[KeyboardButton("No, I don't want to use it")],
[
KeyboardButton(
app._("start_code_yes", "buttons", locale=user.locale)
)
],
[KeyboardButton(app._("start_code_no", "buttons", locale=user.locale))],
],
resize_keyboard=True,
one_time_keyboard=True,
)
await message.reply_text(
f" You have started the bot by the link containing a location **{location.name}**.\n\nPlease, confirm whether you want to use it as your location.",
app._("start_code", "messages", locale=user.locale).format(
name=location.name
),
reply_markup=keyboard,
)
@@ -50,24 +56,24 @@ async def command_start(app: PyroClient, message: Message):
if answer is None or answer.text == "/cancel":
await message.reply_text(
"Cancelled.", reply_markup=ReplyKeyboardRemove()
app._("cancelled", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
if answer.text not in [
"Yes, I want to use it",
"No, I don't want to use it",
]:
if answer.text not in app.in_all_locales(
"start_code_yes", "buttons"
) + app.in_all_locales("start_code_no", "buttons"):
await answer.reply_text(
"Please, select a valid location using keyboard 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.text in [
"No, I don't want to use it",
]:
if answer.text in app.in_all_locales("start_code_no", "buttons"):
await answer.reply_text(
"Alright, you're on your own now. Please, use the command /setup to configure your location and start receiving reminders.",
app._("start_selection_no", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
@@ -80,16 +86,24 @@ async def command_start(app: PyroClient, message: Message):
app._("time", "formats", locale=user.locale)
)
await answer.reply_text(
f"✅ Finished! Your location is now **{location.name}**. You will receive reminders about garbage collection {user.offset} d. in advance at {user_time}.\n\nPlease, visit /help if you want to know how to change notifications time or disable them.",
app._("start_selection_yes", "messages", locale=user.locale).format(
name=location.name, offset=user.offset, time=user_time
),
reply_markup=ReplyKeyboardRemove(),
)
return
if user.location is None:
await message.reply_text(
"📍 Let's configure your location. Press the button on pop-up keyboard to start the process.",
app._("start_configure", "messages", locale=user.locale),
reply_markup=ReplyKeyboardMarkup(
[[KeyboardButton(app._("configure", "buttons", locale=user.locale))]],
[
[
KeyboardButton(
app._("start_configure", "buttons", locale=user.locale)
)
]
],
resize_keyboard=True,
one_time_keyboard=True,
),