diff options
| author | Mattias Loverot <mattias@stubin.se> | 2016-08-16 09:38:36 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-17 16:35:19 -0400 |
| commit | 04f0c2ab39396a5b3002d7fe3e2b0648c63ac3cc (patch) | |
| tree | 4f422421d27de26c71b6197f17ee59159b7dd74c | |
| parent | 3db01b2d5824a885871502a940901e8e83c73fde (diff) | |
[1.10.x] Fixed #27069 -- Doc'd which gettext functions may be aliased as _.
Backport of 35ea6d83c8ecea76f49da26d6646c8d21936500f from master
| -rw-r--r-- | docs/topics/i18n/translation.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 3ecd491927..97555508f5 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:: |
