Skip to content

Commit

Permalink
Fix translating after WTForms 3 removed form._get_translations
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmayo committed Oct 16, 2023
1 parent 0b17a3f commit 545f349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions flask_admin/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@


class BaseForm(form.Form):
_translations = Translations()
class Meta:
_translations = Translations()

def get_translations(self, form):
return self._translations

def __init__(self, formdata=None, obj=None, prefix=u'', **kwargs):
self._obj = obj

super(BaseForm, self).__init__(formdata=formdata, obj=obj, prefix=prefix, **kwargs)

def _get_translations(self):
return self._translations


class FormOpts(object):
__slots__ = ['widget_args', 'form_rules']
Expand Down
5 changes: 3 additions & 2 deletions flask_admin/tests/sqla/test_inlineform.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ def ngettext(self, *args):
return 'success!'

class StubBaseForm(form.BaseForm):
def _get_translations(self):
return StubTranslation()
class Meta:
def get_translations(self, form):
return StubTranslation()

# Set up Admin
class UserModelView(ModelView):
Expand Down

0 comments on commit 545f349

Please sign in to comment.