gettext vs ugettext lazy

24 views
Skip to first unread message

ngal...@gmail.com

unread,
Dec 2, 2021, 5:14:05 AM12/2/21
to Django users
Hello
Would like to know the difference and where to use
.Model, Views, Routers, Forms e.t.c
gettext (from django.utils.translation import gettext)
ugettext_lazy(from django.utils.translation import ugettext_lazy)

Aldian Fazrihady

unread,
Dec 2, 2021, 5:26:47 AM12/2/21
to django...@googlegroups.com
Use the lazy version when you know that the translation database won't be ready when the gettext function is invoked, such as in the class variable initialization.

Use the non-lazy version when you know the translation database is ready, such as inside a method.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fc6e8aa7-6206-4b01-bc3f-0bf02a24770en%40googlegroups.com.


--
Regards,

Reply all
Reply to author
Forward
0 new messages