Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed error caused by the fallback implementation of gettext #2586

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flask-Admin

Flask-Admin is now part of Pallets-Eco, an open source organization managed by the
Flask-Admin is now part of Pallets-Eco, an open source organization managed by the
samuelhwilliams marked this conversation as resolved.
Show resolved Hide resolved
Pallets team to facilitate community maintenance of Flask extensions. Please update
your references to `https://github.com/pallets-eco/flask-admin.git`.

Expand Down
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Fixes:

* Jinja templates can now be loaded in StrictUndefined mode.
* Remove an implicit dependency on `packaging`
* Fixed an error caused by the fallback implementation of `gettext()` (when used in templates)

2.0.0a2
-------
Expand Down
4 changes: 2 additions & 2 deletions flask_admin/babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
except ImportError:

def gettext(string, **variables):
return string % variables
return string if not variables else string % variables
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based directly on flask-babel implementation.


def ngettext(singular, plural, num, **variables):
variables.setdefault("num", num)
return (singular if num == 1 else plural) % variables
return gettext((singular if num == 1 else plural), **variables)

def lazy_gettext(string, **variables):
return gettext(string, **variables)
Expand Down
Loading