gpt4 book ai didi

python - Django:如何检测翻译是否被激活?

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:53 24 4
gpt4 key购买 nike

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

关于python - Django:如何检测翻译是否被激活?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1605706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com