]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
add note about ugettext 1136/head
authorDavid Lord <davidism@gmail.com>
Wed, 29 Jan 2020 14:17:56 +0000 (06:17 -0800)
committerDavid Lord <davidism@gmail.com>
Wed, 5 Feb 2020 16:44:19 +0000 (08:44 -0800)
src/jinja2/ext.py

index 7c36bb4306b8187a645f119633a7c7200c39e741..533ff1795afa74fc14c3612c4b0c95ebc675e76c 100644 (file)
@@ -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