add translation support for pi command

This commit is contained in:
louis chauvet 2018-09-01 11:27:48 +02:00
parent c1241e3734
commit 22c7a61342
2 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import os import os
import traductions as tr
class MainClass: class MainClass:
@ -9,16 +10,17 @@ class MainClass:
self.pi_file = "D:\\Users\\louis chauvet\\Documents\\GitHub\\foBot\\modules\\pi\\pi1.txt" self.pi_file = "D:\\Users\\louis chauvet\\Documents\\GitHub\\foBot\\modules\\pi\\pi1.txt"
async def pi(self, msg, command, args): async def pi(self, msg, command, args):
start=0 start = 0
if len(args) == 1: if len(args) == 1:
try: try:
start = int(args[0]) start = int(args[0])
except ValueError: except ValueError:
await msg.channel.send("Vous devez spwcifier un nombre imferieur a 100000") await msg.channel.send(tr.tr[self.guild.config["lang"]]["Errors"]["TooBigNumberPiError"])
with open(self.pi_file) as pi_file: with open(self.pi_file) as pi_file:
pi_file.read(start) pi_file.read(start)
txt = pi_file.read(1900) txt = pi_file.read(2000)
await msg.channel.send("3."+txt) await msg.channel.send(tr.tr[self.guild.config["lang"]]["modules"]["pi"]["pi"].format(debut=start))
await msg.channel.send(txt)
async def pi_search(self, msg, command, args): async def pi_search(self, msg, command, args):
pass pass

View File

@ -106,6 +106,19 @@ tr = {
}, },
}, },
}, },
"pi": {
"description": "Commandes relatives au nombre pi",
"help": {
"pi": {
"description": "Donne 2000 décimales de pi.",
"examples": [
("`(prefix}pi`", "Affiche les 2000 premières décimales de pi."),
("`{prefix}pi 2000`", "Affiche 2000 décimales de pi à partir de la 2000ème"),
],
},
},
"pi": "Voici les 2000 décimales de pi que vous avez demandé (à partir de la {debut}ème):",
},
}, },
"errors": { "errors": {
"LangNotFoundError": "La langue {lang} est introuvable, tapez {prefix}list_lang pour voir les langues " "LangNotFoundError": "La langue {lang} est introuvable, tapez {prefix}list_lang pour voir les langues "
@ -132,7 +145,8 @@ tr = {
"NotEnoughParamError": "Il manque un ou plusieurs parametres à la commande.", "NotEnoughParamError": "Il manque un ou plusieurs parametres à la commande.",
"NoMentionsError": "Vous devez mentioner un utilisateur pour le rajouter à la liste des administrateurs " "NoMentionsError": "Vous devez mentioner un utilisateur pour le rajouter à la liste des administrateurs "
"du bot.", "du bot.",
"CommandNotFoundError": "La commande {command} n'existe pas." "CommandNotFoundError": "La commande {command} n'existe pas.",
"TooBigNumberPiError": "Vous devez spécifier un nombre inferieur a 10000.",
}, },
}, },
} }