Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
488af54f
Commit
488af54f
authored
Oct 10, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix translations for validation errors
parent
520d2506
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
babel.py
flask_admin/babel.py
+23
-0
__init__.py
flask_admin/form/__init__.py
+6
-0
No files found.
flask_admin/babel.py
View file @
488af54f
...
...
@@ -11,6 +11,13 @@ except ImportError:
def
lazy_gettext
(
string
,
**
variables
):
return
gettext
(
string
,
**
variables
)
class
Translations
(
object
):
''' dummy Translations class for WTForms, no translation support '''
def
gettext
(
self
,
string
):
return
gettext
(
string
)
def
ngettext
(
self
,
singular
,
plural
,
n
):
return
ngettext
(
singular
,
plural
,
n
)
else
:
from
flask_admin
import
translations
...
...
@@ -34,5 +41,21 @@ else:
ngettext
=
domain
.
ngettext
lazy_gettext
=
domain
.
lazy_gettext
try
:
from
wtforms.i18n
import
messages_path
except
ImportError
:
from
wtforms.ext.i18n.utils
import
messages_path
wtforms_domain
=
Domain
(
messages_path
(),
domain
=
'wtforms'
)
class
Translations
(
object
):
''' Fixes WTForms translation support and uses wtforms translations '''
def
gettext
(
self
,
string
):
return
wtforms_domain
.
gettext
(
string
)
def
ngettext
(
self
,
singular
,
plural
,
n
):
return
wtforms_domain
.
ngettext
(
singular
,
plural
,
n
)
# lazy imports
from
.helpers
import
get_current_view
flask_admin/form/__init__.py
View file @
488af54f
from
wtforms
import
form
,
__version__
as
wtforms_version
from
wtforms.fields.core
import
UnboundField
from
flask_admin.babel
import
Translations
from
.fields
import
*
from
.widgets
import
*
...
...
@@ -7,11 +8,16 @@ from .upload import *
class
BaseForm
(
form
.
Form
):
_translations
=
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'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment