From bf3003c4b7cfd94c5787ee24669c4087e5103d36 Mon Sep 17 00:00:00 2001 From: Davte Date: Sun, 18 Aug 2019 18:39:04 +0200 Subject: [PATCH] Multilanguage support for location functions --- ciclopibot/ciclopi.py | 25 ++++++++++++++++--------- ciclopibot/messages.py | 23 ++++++++++++++++++++++- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ciclopibot/ciclopi.py b/ciclopibot/ciclopi.py index e91d142..86e207d 100644 --- a/ciclopibot/ciclopi.py +++ b/ciclopibot/ciclopi.py @@ -1458,8 +1458,6 @@ async def _ciclopi_button_favourites(bot, update, user_record, arguments): ) return result, text, reply_markup -# TODO: Multilanguage support from this line - async def _ciclopi_button_setpos(bot, update, user_record, arguments): 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 0 ) - result = "Inviami una posizione!" + result = bot.get_message( + 'ciclopi', 'button', 'location', 'popup', + update=update, user_record=user_record + ) bot.set_individual_location_handler( await async_wrapper( set_ciclopi_location @@ -1482,22 +1483,28 @@ async def _ciclopi_button_setpos(bot, update, user_record, arguments): asyncio.ensure_future( bot.send_message( chat_id=chat_id, - text=( - "Inviami una posizione.\n" - "Per inviare la tua posizione attuale, usa il " - "pulsante." + text=bot.get_message( + 'ciclopi', 'button', 'location', 'instructions', + update=update, user_record=user_record ), reply_markup=dict( keyboard=[ [ 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 ) ], [ dict( - text="Annulla" + text=bot.get_message( + 'ciclopi', 'button', 'location', 'cancel', + update=update, user_record=user_record + ), ) ] ], diff --git a/ciclopibot/messages.py b/ciclopibot/messages.py index db3d0d4..12128c2 100644 --- a/ciclopibot/messages.py +++ b/ciclopibot/messages.py @@ -360,6 +360,27 @@ default_ciclopi_messages = { "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", + }, + }, } }