WIP: Locale strings
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
from bson.son import SON
|
||||
from convopyro import listen_message
|
||||
from pykeyboard import ReplyButton, ReplyKeyboard
|
||||
from pyrogram.types import Message, ReplyKeyboardRemove
|
||||
@@ -12,6 +11,8 @@ from modules.search_name import search_name
|
||||
|
||||
|
||||
async def search_nearby(app: PyroClient, message: Message) -> Union[Location, None]:
|
||||
user = await app.find_user(message.from_user)
|
||||
|
||||
query = {
|
||||
"location": {
|
||||
"$within": {
|
||||
@@ -27,7 +28,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
|
||||
|
||||
if len(locations) == 0:
|
||||
await message.reply_text(
|
||||
"Could not find any locations nearby. Let's try using the name search."
|
||||
app._("search_nearby_empty", "messages", locale=user.locale)
|
||||
)
|
||||
return await search_name(app, message)
|
||||
|
||||
@@ -35,7 +36,8 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
|
||||
keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations])
|
||||
|
||||
await message.reply_text(
|
||||
"Select the location using the keyboard", reply_markup=keyboard
|
||||
app._("location_select", "messages", locale=user.locale),
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
|
||||
while True:
|
||||
@@ -43,7 +45,10 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
|
||||
location: Union[Location, None] = None
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text("Cancelled.", reply_markup=ReplyKeyboardRemove())
|
||||
await message.reply_text(
|
||||
app._("cancelled", "messages", locale=user.locale),
|
||||
reply_markup=ReplyKeyboardRemove(),
|
||||
)
|
||||
return
|
||||
|
||||
for db_record in locations:
|
||||
@@ -53,7 +58,9 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
|
||||
|
||||
if answer.text is None or location is None:
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user