Updated locale strings

This commit is contained in:
2023-08-30 11:01:59 +02:00
parent 9cda8859da
commit 9403c087cc
6 changed files with 81 additions and 51 deletions

View File

@@ -8,5 +8,7 @@ from classes.pyroclient import PyroClient
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore
)
async def command_remove_commands(app: PyroClient, message: Message):
await message.reply_text("Okay.")
user = await app.find_user(message.from_user)
await message.reply_text(app._("commands_removed", "messages", locale=user.locale))
await app.remove_commands(command_sets=await app.collect_commands())

View File

@@ -17,8 +17,10 @@ async def command_set_offset(app: PyroClient, message: Message):
user = await app.find_user(message.from_user)
await message.reply_text(
"Alright. Please, send how many days in advance do you want to get a notification about the collection.",
reply_markup=ForceReply(placeholder="Number of days"),
app._("set_offset", "messages", locale=user.locale),
reply_markup=ForceReply(
placeholder=app._("set_offset", "force_replies", locale=user.locale)
),
)
while True:
@@ -39,7 +41,9 @@ async def command_set_offset(app: PyroClient, message: Message):
)
except (ValueError, TypeError):
await answer.reply_text(
"Please, provide a valid integer number of days in range 0 to 7 (inclusive). Use /cancel if you want to cancel this operation."
app._("set_offset_invalid", "messages", locale=user.locale).format(
cancel_notice=app._("cancel", "messages", locale=user.locale)
)
)
continue
@@ -51,13 +55,17 @@ async def command_set_offset(app: PyroClient, message: Message):
logger.info("User %s has set offset to %s", user.id, offset)
notice = "" if user.enabled else "Execute /toggle to enable notifications."
garbage_time = datetime(
1970, 1, 1, hour=user.time_hour, minute=user.time_minute
).strftime(app._("time", "formats"))
await answer.reply_text(
f"Notifications time has been updated! You will now receive notification about collection **{offset} d.** before the collection at {garbage_time}. {notice}",
app._("set_offset_finished", "messages", locale=user.locale).format(
offset=offset,
time=garbage_time,
toggle_notice=""
if user.enabled
else app._("toggle", "messages", locale=user.locale),
),
reply_markup=ReplyKeyboardRemove(),
)

View File

@@ -17,8 +17,10 @@ async def command_set_time(app: PyroClient, message: Message):
user = await app.find_user(message.from_user)
await message.reply_text(
"Alright. Please, send your desired time in HH:MM format.",
reply_markup=ForceReply(placeholder="Time as HH:MM"),
app._("set_time", "messages", locale=user.locale),
reply_markup=ForceReply(
placeholder=app._("set_time", "force_replies", locale=user.locale)
),
)
while True:
@@ -35,7 +37,9 @@ async def command_set_time(app: PyroClient, message: Message):
datetime.strptime(answer.text, "%H:%M")
except ValueError:
await answer.reply_text(
"Please, provide a valid time in HH:MM format. Use /cancel if you want to cancel this operation."
app._("set_time_invalid", "messages", locale=user.locale).format(
cancel_notice=app._("cancel", "messages", locale=user.locale)
)
)
continue
@@ -51,11 +55,15 @@ async def command_set_time(app: PyroClient, message: Message):
user_time.strftime("%H:%M"),
)
notice = "" if user.enabled else "Execute /toggle to enable notifications."
garbage_time = user_time.strftime(app._("time", "formats"))
await answer.reply_text(
f"Notifications time has been updated! You will now receive notification about collection {user.offset} d. before the collection at **{garbage_time}**. {notice}",
app._("set_time_finished", "messages", locale=user.locale).format(
offset=user.offset,
time=garbage_time,
toggle_notice=""
if user.enabled
else app._("toggle", "messages", locale=user.locale),
),
reply_markup=ReplyKeyboardRemove(),
)

View File

@@ -22,12 +22,14 @@ async def command_setup(app: PyroClient, message: Message):
keyboard_type = ReplyKeyboard(resize_keyboard=True, row_width=1)
keyboard_type.add(
ReplyButton("Search nearby locations", request_location=True),
ReplyButton("Search by location name"),
ReplyButton(
app._("search_nearby", "buttons", locale=user.locale), request_location=True
),
ReplyButton(app._("search_name", "buttons", locale=user.locale)),
)
await message.reply_text(
"Let's begin configuration with the search for your location.\n\nPlease, select whether you want to search among the locations near you or go straight to the search by location name.\n\nNote that the location you send will **NOT** be saved anywhere and is only used for location lookup in the database.",
app._("setup", "messages", locale=user.locale),
reply_markup=keyboard_type,
)
@@ -41,9 +43,9 @@ async def command_setup(app: PyroClient, message: Message):
)
return
if answer_type.location is None and answer_type.text not in [
"Search by location name",
]:
if answer_type.location is None and answer_type.text not in app.in_all_locales(
"search_name", "buttons"
):
await answer_type.reply_text(
app._("selection_invalid", "messages", locale=user.locale).format(
cancel_notice=app._("cancel", "messages", locale=user.locale)
@@ -61,16 +63,22 @@ async def command_setup(app: PyroClient, message: Message):
if location is None:
await answer_type.reply_text(
"If you want try selecting the location again, use the /setup command.",
app._("setup_retry", "messages", locale=user.locale),
reply_markup=ReplyKeyboardRemove(),
)
return
await user.update_location(location.id)
user_time = datetime(1970, 1, 1, user.time_hour, user.time_minute)
user_time = datetime(1970, 1, 1, user.time_hour, user.time_minute).strftime(
app._("time", "formats", locale=user.locale)
)
await message.reply_text(
f"✅ Finished! Your location is now **{location.name}**. You will receive the notifications about garbage collection {user.offset} d. in advance at {user_time.strftime(app._('time', 'formats', locale=user.locale))}.",
app._("setup_finished", "messages", locale=user.locale).format(
name=location.name,
offset=user.offset,
time=user_time,
),
reply_markup=ReplyKeyboardRemove(),
)