开发者

Django LocaleMiddleware determines the language for me. How do I know what language it determined?

I need to know what language it returns, so that I can perform my own actions.开发者_运维问答


from django.utils import translation

def myview(...):
    ...
    lang = translation.get_language()
    ...

This will return the language code used in the current thread, so in your case, that set by the middleware.


templates with RequestContext have {{ LANGUAGE_CODE }} by default. http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#other-tags

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜