From d2eab8868e479b87fbdf129ffc1a87886d68266e Mon Sep 17 00:00:00 2001 From: Elrond Date: Tue, 24 Apr 2012 00:12:18 +0200 Subject: [PATCH] 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! --- mediagoblin/templates/mediagoblin/utils/wtforms.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -%} -- 2.25.1