Multilanguage support for /help and /language commands

This commit is contained in:
Davte 2019-07-26 23:39:17 +02:00
parent d888d27ef6
commit 534f5c4229
4 changed files with 47 additions and 19 deletions

View File

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

View File

@ -20,6 +20,10 @@ language_messages = {
'en': "/language", 'en': "/language",
'it': "/lingua" 'it': "/lingua"
}, },
'reply_keyboard_button': {
'en': "Language 🗣",
'it': "Lingua 🗣"
},
'alias': { 'alias': {
'en': "Language 🗣", 'en': "Language 🗣",
'it': "Lingua 🗣" 'it': "Lingua 🗣"
@ -33,6 +37,10 @@ language_messages = {
'description': { 'description': {
'en': "Change language settings", 'en': "Change language settings",
'it': "Cambia le impostazioni della lingua" 'it': "Cambia le impostazioni della lingua"
},
'language_set': {
'en': "Selected language: English 🇬🇧",
'it': "Lingua selezionata: Italiano 🇮🇹"
} }
}, },
'language_panel': { 'language_panel': {
@ -59,10 +67,8 @@ ciclopibot_help_messages = {
'text': { 'text': {
'en': "<b>📖 {bot.name} guide</b>\n\n" 'en': "<b>📖 {bot.name} guide</b>\n\n"
"Welcome!\n" "Welcome!\n"
"To visit a guide section, press the corresponding " "To visit a guide section, press the corresponding button.\n"
"button.\n" "To view all available commands, see section `Comandi`.\n\n"
"To view all available commands, see section "
"`Comandi`.\n\n"
"Bot author and administrator: @Davte", "Bot author and administrator: @Davte",
'it': "<b>📖 Guida di {bot.name}\n\n</b>" 'it': "<b>📖 Guida di {bot.name}\n\n</b>"
"Benvenuto!\n" "Benvenuto!\n"
@ -72,14 +78,24 @@ ciclopibot_help_messages = {
"premendo il pulsante Comandi.\n\n" "premendo il pulsante Comandi.\n\n"
"Autore e amministratore del bot: @Davte" "Autore e amministratore del bot: @Davte"
}, },
'reply_keyboard_button': {
'en': "Help 📖",
'it': "Guida 📖"
},
'description': { 'description': {
'en': "Help", 'en': "Help",
'it': "Aiuto" 'it': "Aiuto"
},
'access_denied_message': {
'en': "Ask for authorization. If your request is accepted, send "
"/help command again to read the guide.",
'it': "Chiedi di essere autorizzato: se la tua richiesta "
"verrà accolta, ripeti il comando /help per leggere "
"il messaggio di aiuto."
} }
} }
} }
if __name__ == '__main__': if __name__ == '__main__':
path = os.path.dirname(__file__) path = os.path.dirname(__file__)
try: try:

View File

@ -20,6 +20,10 @@ default_ciclopi_messages = {
'description': { 'description': {
'en': "CiloPi stations status", 'en': "CiloPi stations status",
'it': "Stato delle stazioni CicloPi" 'it': "Stato delle stazioni CicloPi"
},
'reply_keyboard_button': {
'en': "CicloPi 🚲",
'it': "CicloPi 🚲"
} }
} }
} }
@ -1497,6 +1501,8 @@ def init(bot, ciclopi_messages=None):
ciclopi_messages = default_ciclopi_messages ciclopi_messages = default_ciclopi_messages
@bot.command(command='/ciclopi', aliases=["CicloPi 🚲", "🚲 CicloPi 🔴"], @bot.command(command='/ciclopi', aliases=["CicloPi 🚲", "🚲 CicloPi 🔴"],
reply_keyboard_button=default_ciclopi_messages[
'ciclopi_command']['reply_keyboard_button'],
show_in_keyboard=True, show_in_keyboard=True,
description=( description=(
ciclopi_messages['ciclopi_command']['description'] ciclopi_messages['ciclopi_command']['description']

View File

@ -12,6 +12,10 @@ default_help_messages = {
'en': "<b>Guide</b>", 'en': "<b>Guide</b>",
'it': "<b>Guida</b>" 'it': "<b>Guida</b>"
}, },
'reply_keyboard_button': {
'en': "Help 📖",
'it': "Guida 📖"
},
'description': { 'description': {
'en': "Help", 'en': "Help",
'it': "Aiuto" 'it': "Aiuto"
@ -215,7 +219,9 @@ def init(bot, help_messages=None,
async def start_command(bot, update, user_record): async def start_command(bot, update, user_record):
return await _start_command(bot, update, user_record) return await _start_command(bot, update, user_record)
@bot.command(command='/help', aliases=['Guida 📖', '00help'], @bot.command(command='/help', aliases=['Guida 📖', 'Help 📖', '00help'],
reply_keyboard_button=help_messages['help_command'][
'reply_keyboard_button'],
show_in_keyboard=True, show_in_keyboard=True,
description=help_messages['help_command']['description'], description=help_messages['help_command']['description'],
authorization_level='everybody') authorization_level='everybody')