Differences between Django ugettext and ugettext_lazy

Posted by kRON on Stack Overflow See other posts from Stack Overflow or by kRON
Published on 2010-04-28T15:10:17Z Indexed on 2010/04/28 15:13 UTC
Read the original article Hit count: 781

Filed under:
|
|
|

I keep rereading the Django's internationalization documentation and still don't understand when and why should I use django.translation.ugettext_lazy as opposed to django.translation.ugettext?

I understand that using ugettext_lazy means that I will deffer from translating the string until the very end.

Is it because Django parses the Accept-Language request header or the request.URL for the language code very late during the execution, which would mean that I may not be targeting the user's preferred language code if I was using ugettext?

Would that ultimately mean that I should only use ugettext if I want to enforce that the message gets explicitly translated to the language specified in settings.LANGUAGE_CODE, or the currently active language as per django.translation.get_language()?

© Stack Overflow or respective owner

Related posts about django

Related posts about i18n