django.utils.translation.get_language() 如果未激活翻译,则返回默认语言环境。有没有办法找出翻译是否被激活(通过 translation.activate())?
请您参考如下方法:
非常 hacky,但至少应该在 1.1.1 中工作:
import django.utils.translation.trans_real as trans
from django.utils.thread_support import currentThread
def isactive():
return currentThread() in trans._active
