From: Elrond Date: Mon, 23 Apr 2012 22:12:18 +0000 (+0200) Subject: Translate form validation error messages. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d2eab8868e479b87fbdf129ffc1a87886d68266e;p=mediagoblin.git 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! --- diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index a85a3d96..58ecb8e0 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -25,7 +25,7 @@ {{ field }} {%- if field.errors -%} {% for error in field.errors %} -

{{ error }}

+

{{ _(error) }}

{% endfor %} {%- endif %} {% if field.description -%}