Is there a way to force a template to get translated to a certain language without passing RequestContext?
I'm rendering a template with a managemen开发者_JAVA技巧t command (something I need for producing documentation in my native language). So I've no request object, so no RequestContext. Is there a way I can force the template rendering process to lookup translation strings from a particular language other than English?
In case someone else needs something like this. You need to do the following before rendering the template:
from django.utils import translation
translation.activate(cur_language)
where cur_language is the language code for the language you want.
You could try setting settings.LANGUAGE_CODE
directly in your management command.
精彩评论