diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-10-18 08:57:21 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-10-18 09:02:20 +0200 |
| commit | 0775ab295566ccb306b8ae6340d2690c3d0aa6af (patch) | |
| tree | 09b7b79cc2717ddfa99cc42be32b13516c481320 /docs | |
| parent | 31dcaf49a0ed6bda13a6d556412b6993a9bd41ba (diff) | |
Fixed #19132 -- Added example for creating custom lazy function
Thanks flagzeta@yahoo.it for the report and Luke Plant for his
expert assistance.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/i18n/translation.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index aaf728b1af..65c6fe2445 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -427,6 +427,24 @@ In this case, the lazy translations in ``result`` will only be converted to strings when ``result`` itself is used in a string (usually at template rendering time). +Other uses of lazy in delayed translations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For any other case where you would like to delay the translation, but have to +pass the translatable string as argument to another function, you can wrap +this function inside a lazy call yourself. For example:: + + from django.utils import six # Python 3 compatibility + from django.utils.functional import lazy + from django.utils.safestring import mark_safe + from django.utils.translation import ugettext_lazy as _ + + mark_safe_lazy = lazy(mark_safe, six.text_type) + +And then later:: + + lazy_string = mark_safe_lazy(_("<p>My <strong>string!</strong></p>")) + Localized names of languages ---------------------------- |
