1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

[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 136a5f9409 from main.
This commit is contained in:
lufafajoshua
2024-06-12 13:13:01 +03:00
committed by Sarah Boyce
parent b4dd76c315
commit c833cb36a2

View File

@@ -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
----------------------------