Traduction de chaines en anglais

This commit is contained in:
Guyot 2020-04-30 23:33:25 +02:00
parent 76ed596f48
commit d6e4046c8f
2 changed files with 54 additions and 31 deletions

View File

@ -55,3 +55,27 @@ msgstr "trace le graphe : optionnel"
msgid "optional : undo remove the last line removed" msgid "optional : undo remove the last line removed"
msgstr "annule la suppression de la dernière ligne effacée : optionnel" msgstr "annule la suppression de la dernière ligne effacée : optionnel"
msgid "Your measure has been recorded : "
msgstr "Votre mesure a été enregistrée : "
msgid "-your weight : {weight} kg"
msgstr "-votre poids : {weight} kg"
msgid "-its type : {typ}"
msgstr "-son type : {typ}"
msgid "-the date : {dat}"
msgstr "-la date : {dat}"
msgid "-the metric : {metric}"
msgstr "-la métrique : {metric}"
msgid "-the identifier : {ide}"
msgstr "-l'identifiant : {ide}"
msgid "-your comment : {comment}"
msgstr "-votre commentaire : {comment}"
msgid "-other : {other}"
msgstr "-autre : {other}"

View File

@ -40,18 +40,18 @@ _ = en.gettext # english
# Voir : https://medium.com/i18n-and-l10n-resources-for-developers/how-to-translate-python-applications-with-the-gnu-gettext-module-5c1c085041 # Voir : https://medium.com/i18n-and-l10n-resources-for-developers/how-to-translate-python-applications-with-the-gnu-gettext-module-5c1c085041
""" """
Une mesure est caractérisée par : A measurement is characterized by :
- sa valeur - its value
- son type - its type
- sa date - its date
- sa métrique - its metrics
- son identifiant - its identifier
- un commentaire - one comment
- autre - other
""" """
def save_file_data(): def save_file_data():
""" Enregistrement du nom du fichier de données """ """ Saving the data file name """
f = open("Fonctionnel.txt", "r") f = open("Fonctionnel.txt", "r")
contents = f.readlines() contents = f.readlines()
f.close() f.close()
@ -68,16 +68,16 @@ def save_file_data():
def save_mesure(): def save_mesure():
""" Affichage et enregistrement d'une mesure """ """ Displaying and recording a measure """
print("Votre mesure a été enregistrée : ") print(_("Your measure has been recorded"))
with indent(4, quote=colored.blue('')): with indent(4, quote=colored.blue('')):
puts(colored.green("-votre poids : {weight} kg").format(weight=args.weight)) puts(colored.green("-your weight : {weight} kg").format(weight=args.weight))
puts("-son type : {typ}".format(typ=args.type)) puts("-its type : {typ}".format(typ=args.type))
puts("-la date : {dat}".format(dat=args.date)) puts("-the date : {dat}".format(dat=args.date))
puts("-la métrique : {metric}".format(metric=args.metric)) puts("-the metric : {metric}".format(metric=args.metric))
puts("-l'identifiant : {ide}".format(ide=args.id)) puts("-the identifier : {ide}".format(ide=args.id))
puts("-votre commentaire : {comment}".format(comment=args.comment)) puts("-your comment : {comment}".format(comment=args.comment))
puts("-autre : {other}".format(other=args.other)) puts("-other : {other}".format(other=args.other))
with open(str(args.data), 'a', newline='\n') as csvfile: with open(str(args.data), 'a', newline='\n') as csvfile:
weightwriter = csv.writer(csvfile, delimiter='|', quotechar='"', quoting=csv.QUOTE_MINIMAL) weightwriter = csv.writer(csvfile, delimiter='|', quotechar='"', quoting=csv.QUOTE_MINIMAL)
weightwriter.writerow([str(args.weight), \ weightwriter.writerow([str(args.weight), \
@ -88,7 +88,7 @@ def save_mesure():
str(args.other)]) str(args.other)])
def read_measures(): def read_measures():
""" Affichage de l'ensemble des mesures """ """ Display of all measures """
data_file = open(str(args.data), 'r') data_file = open(str(args.data), 'r')
data = csv.reader(data_file, delimiter='|') data = csv.reader(data_file, delimiter='|')
linenum = 0 linenum = 0
@ -138,8 +138,8 @@ def undo_remove():
f.write(contents) f.write(contents)
f.close() f.close()
def trace_graph(): def plot_graph():
""" Trace le graphe de l'évolution du poids avec Gnuplot """ """ Plot the graph of the weight evolution with Gnuplot """
if args.dates != None: if args.dates != None:
print(args.dates) print(args.dates)
# set xrange [*:*] # set xrange [*:*]
@ -185,23 +185,22 @@ def trace_graph():
def tests_subproc(): def tests_subproc():
""" Test du module subprocess """ """ Test of the subprocess module """
process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE) process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate() stdout, stderr = process.communicate()
print(stdout) print(stdout)
### Main ### ### Main ###
""" Programme de relevé de poids """ Weight Recording Program
Attention, le fichier data.csv à une ligne d'entête à laquelle Be careful, the data.csv file has a header line that lacks
il manque un séparateur | final pour que le nombre de champs soit a final | separator for the number of fields to be correct.
correct.
""" """
# Création du parseur pour les arguments # Creating the parser for arguments
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
texte = _('A script to manage your weight in command line.') texte = _('A script to manage your weight in command line.')
parser.description=texte parser.description=texte
# Création des arguments # Creating arguments
parser.add_argument('-da', '--data', parser.add_argument('-da', '--data',
default='data2.csv', default='data2.csv',
help=_('optional : file data') help=_('optional : file data')
@ -264,9 +263,9 @@ parser.add_argument('-v', '--version',
version='0.0.5', version='0.0.5',
action='version' action='version'
) )
# Récupération des arguments # Argument retrieval
args = parser.parse_args() args = parser.parse_args()
# Lancement des actions # Launching of actions
if args.data != 'data2.csv': if args.data != 'data2.csv':
save_file_data() save_file_data()
if args.weight != -1: if args.weight != -1:
@ -276,7 +275,7 @@ if args.read:
if args.remove >= 0: if args.remove >= 0:
remove_measure() remove_measure()
if args.graph: if args.graph:
trace_graph() plot_graph()
if args.tests: if args.tests:
tests_subproc() tests_subproc()
if args.undoremove: if args.undoremove: