Multilanguage support for location functions

This commit is contained in:
Davte 2019-08-18 18:39:04 +02:00
parent 4ad925cd06
commit bf3003c4b7
2 changed files with 38 additions and 10 deletions

View File

@ -1458,8 +1458,6 @@ async def _ciclopi_button_favourites(bot, update, user_record, arguments):
) )
return result, text, reply_markup return result, text, reply_markup
# TODO: Multilanguage support from this line
async def _ciclopi_button_setpos(bot, update, user_record, arguments): async def _ciclopi_button_setpos(bot, update, user_record, arguments):
result, text, reply_markup = '', '', None result, text, reply_markup = '', '', None
@ -1468,7 +1466,10 @@ async def _ciclopi_button_setpos(bot, update, user_record, arguments):
else update['chat']['id'] if 'chat' in update else update['chat']['id'] if 'chat' in update
else 0 else 0
) )
result = "Inviami una posizione!" result = bot.get_message(
'ciclopi', 'button', 'location', 'popup',
update=update, user_record=user_record
)
bot.set_individual_location_handler( bot.set_individual_location_handler(
await async_wrapper( await async_wrapper(
set_ciclopi_location set_ciclopi_location
@ -1482,22 +1483,28 @@ async def _ciclopi_button_setpos(bot, update, user_record, arguments):
asyncio.ensure_future( asyncio.ensure_future(
bot.send_message( bot.send_message(
chat_id=chat_id, chat_id=chat_id,
text=( text=bot.get_message(
"Inviami una posizione.\n" 'ciclopi', 'button', 'location', 'instructions',
"Per inviare la tua posizione attuale, usa il " update=update, user_record=user_record
"pulsante."
), ),
reply_markup=dict( reply_markup=dict(
keyboard=[ keyboard=[
[ [
dict( dict(
text="Invia la mia posizione", text=bot.get_message(
'ciclopi', 'button', 'location',
'send_current_location',
update=update, user_record=user_record
),
request_location=True request_location=True
) )
], ],
[ [
dict( dict(
text="Annulla" text=bot.get_message(
'ciclopi', 'button', 'location', 'cancel',
update=update, user_record=user_record
),
) )
] ]
], ],

View File

@ -360,6 +360,27 @@ default_ciclopi_messages = {
"preferite.", "preferite.",
}, },
}, },
} },
'location': {
'popup': {
'en': "Send a location!",
'it': "Inviami una posizione!",
},
'instructions': {
'en': "Send a location.\n"
"Use the button to send your current location.",
'it': "Inviami una posizione.\n"
"Per inviare la tua posizione attuale, usa il "
"pulsante.",
},
'send_current_location': {
'en': "Send current location",
'it': "Invia la mia posizione",
},
'cancel': {
'en': "Cancel",
'it': "Annulla",
},
},
} }
} }