From 35ea6d83c8ecea76f49da26d6646c8d21936500f Mon Sep 17 00:00:00 2001 From: Mattias Loverot Date: Tue, 16 Aug 2016 09:38:36 +0200 Subject: [PATCH] Fixed #27069 -- Doc'd which gettext functions may be aliased as _. --- docs/topics/i18n/translation.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index e503e3a3d1..11b62ea4ac 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -70,6 +70,16 @@ as a shorter alias, ``_``, to save typing. global ``_()`` function causes interference. Explicitly importing ``ugettext()`` as ``_()`` avoids this problem. +.. admonition:: What functions may be aliased as ``_``? + + Because of how ``xgettext`` (used by :djadmin:`makemessages`) works, only + functions that take a single string argument can be imported as ``_``: + + * :func:`~django.utils.translation.gettext` + * :func:`~django.utils.translation.gettext_lazy` + * :func:`~django.utils.translation.ugettext` + * :func:`~django.utils.translation.ugettext_lazy` + In this example, the text ``"Welcome to my site."`` is marked as a translation string::