commit 9889641127fa6fe94883edf0106235cf4aaaf463
parent 7428a885e60723b702906db54d2961a3261693a0
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Wed, 30 Jan 2013 23:20:48 +0100
localization
Diffstat:
3 files changed, 69 insertions(+), 25 deletions(-)
diff --git a/plint_web.py b/plint_web.py
@@ -87,10 +87,18 @@ def q():
print(d['poem'])
poem = check(d['poem'])
if not poem:
- d['error'] = "Poem is empty, too long, or has too long lines"
+ if get_locale() == 'fr':
+ msg = "Le poème est vide, trop long, ou a des lignes trop longues"
+ else:
+ msg = "Poem is empty, too long, or has too long lines"
+ d['error'] = msg
return env.get_template('error.html').render(**d)
if not re.match("^[a-z_]+$", d['template']):
- d['error'] = "Invalid template name"
+ if get_locale() == 'fr':
+ msg = "Modèle inexistant"
+ else:
+ msg = "No such template"
+ d['error'] = msg
return env.get_template('error.html').render(**d)
if d['template'] == 'custom':
x = request.forms.get('custom_template')
@@ -100,12 +108,20 @@ def q():
x = f.read()
f.close()
except IOError:
- d['error'] = "No such template"
+ if get_locale() == 'fr':
+ msg = "Modèle inexistant"
+ else:
+ msg = "No such template"
+ d['error'] = msg
return env.get_template('error.html').render(**d)
try:
templ = template.Template(x)
except error.TemplateLoadError as e:
- d['error'] = "Error when reading template: " + e.msg
+ if get_locale() == 'fr':
+ msg = "Erreur à la lecture du modèle : " + e.msg
+ else:
+ msg = "Error when reading template: " + e.msg
+ d['error'] = msg
return env.get_template('error.html').render(**d)
print(d['template'])
print(x)
diff --git a/res/messages_fr.po b/res/messages_fr.po
@@ -5,8 +5,8 @@
msgid ""
msgstr ""
"Project-Id-Version: plint\n"
-"POT-Creation-Date: 2012-07-15 15:31+CEST\n"
-"PO-Revision-Date: 2012-07-15 15:32+0100\n"
+"POT-Creation-Date: 2013-01-30 23:19+CET\n"
+"PO-Revision-Date: 2013-01-30 23:20+0100\n"
"Last-Translator: Antoine Amarilli <a3nm@a3nm.net>\n"
"Language-Team: \n"
"Language: \n"
@@ -23,62 +23,90 @@ msgstr "erreur : %s"
msgid "Line is: %s"
msgstr "Ligne : %s"
-#: error.py:43
+#: error.py:45
msgid "Illegal character%s: %s"
msgstr "Mauvais caractère%s : %s"
-#: error.py:52
+#: error.py:54
msgid "Illegal ambiguous pattern: %s"
msgstr "Motif ambigu interdit : %s"
-#: error.py:60
+#: error.py:62
msgid "Illegal hiatus: %s"
msgstr "Hiatus interdit : %s"
-#: error.py:73
+#: error.py:75
msgid "%s for type %s (expected %s, inferred \"%s\")"
msgstr "%s pour le type %s (attendu : %s, lu : \"%s\")"
-#: error.py:79
+#: error.py:81
msgid " or "
msgstr " ou "
-#: error.py:89
+#: error.py:91
msgid "Bad rhyme genre"
msgstr "Mauvais genre de rime"
-#: error.py:98
+#: error.py:100
msgid " (ending: \""
msgstr " (fin : \""
-#: error.py:104
+#: error.py:106
msgid "%s for type %s (expected %s)"
msgstr "%s pour le type %s (attendu : %s)"
-#: error.py:109
+#: error.py:111
msgid "Bad rhyme"
msgstr "Mauvaise rime"
-#: error.py:179
+#: error.py:181
msgid "Bad metric (expected %s, inferred %d illegal option%s)"
msgstr "Mauvaise métrique (attendu : %s, lu %d choix interdit%s)"
-#: error.py:185
+#: error.py:187
msgid "... worse options omitted ..."
msgstr "... et d'autres choix non affichés ..."
-#: error.py:197
+#: error.py:199
msgid "Too many occurrences of word %s for rhyme %s"
msgstr "Trop d'occurrences du mot %s pour la rime %s"
-#: plint.py:25
+#: error.py:204
+msgid "Poem is not complete"
+msgstr "Poème incomplet"
+
+#: error.py:209
+msgid "Verse is beyond end of poem"
+msgstr "Vers au-delà de la fin du poème"
+
+#: plint.py:30
msgid "Usage: %s TEMPLATE [OCONTEXT]"
msgstr "Usage : %s MODÈLE [OCONTEXTE]"
-#: plint.py:26
+#: plint.py:31
msgid "Check stdin according to TEMPLATE, report errors on stdout"
msgstr "Vérifie l'entrée standard suivant MODÈLE, signale les erreurs sur la sortie standard"
+#: template.py:36
+msgid "Metric length limit exceeded"
+msgstr "La longueur de la métrique est trop grande"
+
+#: template.py:82
+msgid "Bad value for global option %s"
+msgstr "Mauvaise valeur pour l'option globale %s"
+
+#: template.py:92
+msgid "Unknown global option"
+msgstr "Option globale inconnue"
+
+#: template.py:107
+msgid "Template is empty"
+msgstr "Modèle vide"
+
+#: template.py:345
+msgid "Bad value in global option"
+msgstr "Mauvaise valeur pour l'option globale %s"
+
#~ msgid "genre"
#~ msgstr "genre"
diff --git a/template.py b/template.py
@@ -33,7 +33,7 @@ class Pattern:
"""Parse from a metric description"""
verse = [int(x) for x in self.metric.split('/')]
if sum(verse) > 16:
- raise error.TemplateLoadError("Verse length limit exceeded")
+ raise error.TemplateLoadError(_("Metric length limit exceeded"))
self.hemistiches = []
self.length = 0
for v in verse:
@@ -79,7 +79,7 @@ class Template:
value = "classical"
self.diaeresis = value
if value not in ["permissive", "classical"]:
- raise error.TemplateLoadError("Bad value for global option %s" % key)
+ raise error.TemplateLoadError(_("Bad value for global option %s") % key)
elif key in ["check_end_hemistiche", "verifie_fin_hemistiche"]:
self.check_end_hemistiche = str2bool(value)
elif key in ["check_occurrences", "verifie_occurrences"]:
@@ -89,7 +89,7 @@ class Template:
elif key in ["incomplete_ok"]:
self.incomplete_ok = str2bool(value)
else:
- raise error.TemplateLoadError("Unknown global option")
+ raise error.TemplateLoadError(_("Unknown global option"))
def load(self, s):
"""Load from a string"""
@@ -104,7 +104,7 @@ class Template:
else:
self.template.append(self.parse_line(line.strip()))
if len(self.template) == 0:
- raise error.TemplateLoadError("Template is empty")
+ raise error.TemplateLoadError(_("Template is empty"))
def count(self, align):
"""total weight of an align"""
@@ -342,5 +342,5 @@ def str2bool(x):
return True
if x.lower() in ["no", "non", "n"]:
return False
- raise error.TemplateLoadError("Bad value in global option.")
+ raise error.TemplateLoadError(_("Bad value in global option"))