Queer European MD passionate about IT
Browse Source

Multilanguage support for ciclopibot

Davte 4 years ago
parent
commit
44857fd45f
2 changed files with 47 additions and 2 deletions
  1. 1 1
      ciclopibot/__init__.py
  2. 46 1
      ciclopibot/bot.py

+ 1 - 1
ciclopibot/__init__.py

@@ -3,6 +3,6 @@
 __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __license__ = "GNU General Public License v3.0"
-__version__ = "1.0.3"
+__version__ = "1.0.4"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"

+ 46 - 1
ciclopibot/bot.py

@@ -7,7 +7,7 @@ import sys
 
 # Third party modules
 import davtelepot
-from davtelepot import authorization
+from davtelepot import authorization, languages
 
 # Project modules
 from . import bot_tools
@@ -15,6 +15,47 @@ from . import ciclopi
 from . import helper
 from .data.passwords import bot_token
 
+language_messages = {
+    'language_command': {
+        'name': {
+            'en': "/language",
+            'it': "/lingua"
+        },
+        'alias': {
+            'en': "Language 🗣",
+            'it': "Lingua 🗣"
+        },
+        'description': {
+            'en': "Change language settings",
+            'it': "Cambia le impostazioni della lingua"
+        }
+    },
+    'language_button': {
+        'description': {
+            'en': "Change language settings",
+            'it': "Cambia le impostazioni della lingua"
+        }
+    },
+    'language_panel': {
+        'text': {
+            'en': "<b>Choose a language</b>",
+            'it': "<b>Seleziona una lingua</b>"
+        }
+    }
+}
+
+supported_languages = {
+    'en': {
+        'flag': '🇬🇧',
+        'name': 'English'
+    },
+    'it': {
+        'flag': '🇮🇹',
+        'name': 'Italiano'
+    }
+}
+
+
 if __name__ == '__main__':
     path = os.path.dirname(__file__)
     try:
@@ -88,6 +129,10 @@ if __name__ == '__main__':
         help_sections_file='ciclopibot/data/help.json'
     )
     authorization.init(bot, language='it')
+    languages.init(
+        bot, language='it', language_messages=language_messages,
+        supported_languages=supported_languages
+    )
     # Run bot(s)
     logging.info("Presso ctrl+C to exit.")
     exit_state = davtelepot.bot.Bot.run(