summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorlufafajoshua <77637648+lufafajoshua@users.noreply.github.com>2024-06-12 13:13:01 +0300
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-06-25 09:01:25 +0200
commitc833cb36a272c9708a9a80ad02e85ca5e2bcc8c2 (patch)
tree2674bf9b7774a60bb91b9aff12b13d6360e904bc /docs
parentb4dd76c315ff06e4897fd380e0ad0eaf88db8a9d (diff)
[5.1.x] Fixed #34886 -- Modified sample use of lazy in delayed translations.
Modified example to use python standard library function to lower the case of the string. Backport of 136a5f94099e428dd57572ebd16905fb25ef227e from main.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/i18n/translation.txt10
1 files changed, 7 insertions, 3 deletions
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index 41bee79204..273e856910 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -515,14 +515,18 @@ pass the translatable string as argument to another function, you can wrap
this function inside a lazy call yourself. For example::
from django.utils.functional import lazy
- from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
- mark_safe_lazy = lazy(mark_safe, str)
+
+ def to_lower(string):
+ return string.lower()
+
+
+ to_lower_lazy = lazy(to_lower, str)
And then later::
- lazy_string = mark_safe_lazy(_("<p>My <strong>string!</strong></p>"))
+ lazy_string = to_lower_lazy(_("My STRING!"))
Localized names of languages
----------------------------