summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-01-29 06:17:56 -0800
committerDavid Lord <davidism@gmail.com>2020-01-29 06:17:56 -0800
commit8df36e0ed73558a153288320ff5f2f4b67d1a25b (patch)
treeb89ecf5fbff2dc4e17bd9cf39d9f741b9eadc25e
parent76f1e33ff01c7f1e90991e6773a250c219309ba0 (diff)
downloadjinja2-drop-python2.tar.gz
add note about ugettextdrop-python2
-rw-r--r--src/jinja2/ext.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/jinja2/ext.py b/src/jinja2/ext.py
index 7c36bb4..533ff17 100644
--- a/src/jinja2/ext.py
+++ b/src/jinja2/ext.py
@@ -26,11 +26,9 @@ from .runtime import concat
from .utils import contextfunction
from .utils import import_string
-# the only real useful gettext functions for a Jinja template. Note
-# that ugettext must be assigned to gettext as Jinja doesn't support
-# non unicode strings.
+# I18N functions available in Jinja templates. If the I18N library
+# provides ugettext, it will be assigned to gettext.
GETTEXT_FUNCTIONS = ("_", "gettext", "ngettext")
-
_ws_re = re.compile(r"\s*\n\s*")
@@ -192,6 +190,8 @@ class InternationalizationExtension(Extension):
)
def _install(self, translations, newstyle=None):
+ # ugettext and ungettext are preferred in case the I18N library
+ # is providing compatibility with older Python versions.
gettext = getattr(translations, "ugettext", None)
if gettext is None:
gettext = translations.gettext