Queer European MD passionate about IT
Browse Source

Multilanguage support for location functions

Davte 4 years ago
parent
commit
bf3003c4b7
2 changed files with 38 additions and 10 deletions
  1. 16 9
      ciclopibot/ciclopi.py
  2. 22 1
      ciclopibot/messages.py

+ 16 - 9
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
+                            ),
                         )
                     ]
                 ],

+ 22 - 1
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",
+            },
+        },
     }
 }