Translate form validation error messages.

Okay, this is a long story.
There are two ways to translate validation error messages:

1) Let wtforms do it. You give wtforms a translation thingy
   and it calls it for the message to be translated. Good
   idea maybe. Except: The translation function is only
   called for the builtin messages of wtforms. It's not
   called for any handcrafted messages in the constructor.
   And we can't translate the message there! Because the
   message needs to be translated when the form is
   rendered, for each user's locale.

   This does not work for us.

2) Translate the message while it gets rendered.
   Luckily we render the message completely by hand. So we
   can just translate it there also!

   Simple, easy, works!

This all does not cover translating the builtin messages of
wtforms. They're currently not extracted in any way, so our
translators can't translate them.

But that's another issue!
This commit is contained in:
Elrond 2012-04-24 00:12:18 +02:00
parent 80dc071b79
commit d2eab8868e

View File

@ -25,7 +25,7 @@
{{ field }}
{%- if field.errors -%}
{% for error in field.errors %}
<p class="form_field_error">{{ error }}</p>
<p class="form_field_error">{{ _(error) }}</p>
{% endfor %}
{%- endif %}
{% if field.description -%}