summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-10-16 22:18:49 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-10-16 22:18:49 +0200
commit8a6f4b6226228034a4b9076c0641fa19e8b15891 (patch)
tree8d0c70b743050c7942f547c7254df68c91da059a /app
parent3a0fcfcfa90b86dd212b976eca3f212e10e69f8b (diff)
downloadkosten-8a6f4b6226228034a4b9076c0641fa19e8b15891.tar.gz
kosten-8a6f4b6226228034a4b9076c0641fa19e8b15891.tar.bz2
kosten-8a6f4b6226228034a4b9076c0641fa19e8b15891.zip
Fix locale support for forms
Diffstat (limited to 'app')
-rw-r--r--app/forms.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/forms.py b/app/forms.py
index e744934..8cf9b6e 100644
--- a/app/forms.py
+++ b/app/forms.py
@@ -6,6 +6,7 @@ from wtforms import validators as v
from wtforms import fields
from wtforms.ext.sqlalchemy.fields import QuerySelectField
+from wtforms.ext.i18n.form import Form as i18nForm
import datetime
@@ -26,8 +27,10 @@ class DecimalField(fields.DecimalField):
req = [v.input_required()]
-class Form(_Form):
- LOCALES = ['de_DE', 'de']
+class Form(_Form, i18nForm):
+ # docs say LOCALES, code says LANGUAGES ... use both :)
+ LANGUAGES = LOCALES = ['de_DE', 'de']
+
def __init__ (self, *args, **kwargs):
self._msg = kwargs.pop('flash', u"Fehler im Formular!")
_Form.__init__(self, *args, **kwargs)
@@ -45,6 +48,12 @@ class Form(_Form):
def validate_on_submit (self):
return self.is_submitted() and self.flash_validate()
+ def _get_translations(self):
+ # use WTForms builtin translation support instead of the flask-babael
+ # stuff added by flask-wtf
+ # FIXME: remove this, if flask-babel is used in the app
+ return i18nForm._get_translations(self)
+
class ExpenseForm(Form):
date = DateField(u'Datum', req,
format="%d.%m.%Y",