From 22c7a6134230433cfa1231785a98965176d612fe Mon Sep 17 00:00:00 2001 From: louis chauvet Date: Sat, 1 Sep 2018 11:27:48 +0200 Subject: [PATCH] add translation support for pi command --- modules/pi.py | 10 ++++++---- traductions.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/pi.py b/modules/pi.py index 37e0787..d8ac276 100644 --- a/modules/pi.py +++ b/modules/pi.py @@ -1,4 +1,5 @@ import os +import traductions as tr class MainClass: @@ -9,16 +10,17 @@ class MainClass: self.pi_file = "D:\\Users\\louis chauvet\\Documents\\GitHub\\foBot\\modules\\pi\\pi1.txt" async def pi(self, msg, command, args): - start=0 + start = 0 if len(args) == 1: try: start = int(args[0]) 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: pi_file.read(start) - txt = pi_file.read(1900) - await msg.channel.send("3."+txt) + txt = pi_file.read(2000) + 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): pass diff --git a/traductions.py b/traductions.py index 3a25d36..8fdd558 100644 --- a/traductions.py +++ b/traductions.py @@ -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": { "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.", "NoMentionsError": "Vous devez mentioner un utilisateur pour le rajouter à la liste des administrateurs " "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.", }, }, }