Skip to content

Commit

Permalink
Merge pull request #2586 from LeXofLeviafan/fix-gettext-error
Browse files Browse the repository at this point in the history
fixed error caused by the fallback implementation of gettext
  • Loading branch information
samuelhwilliams authored Jan 1, 2025
2 parents a4e7be8 + 250e4d7 commit d9fffcf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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
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

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

0 comments on commit d9fffcf

Please sign in to comment.