1
0
forked from s434650/CatOrNot
docs/venv/lib/python3.6/site-packages/wtforms/ext/django/i18n.py

25 lines
626 B
Python
Raw Normal View History

2018-12-11 00:32:28 +01:00
from django.utils.translation import ugettext, ungettext
from wtforms import form
class DjangoTranslations(object):
"""
A translations object for WTForms that gets its messages from django's
translations providers.
"""
def gettext(self, string):
return ugettext(string)
def ngettext(self, singular, plural, n):
return ungettext(singular, plural, n)
class Form(form.Form):
"""
A Form derivative which uses the translations engine from django.
"""
_django_translations = DjangoTranslations()
def _get_translations(self):
return self._django_translations