Django i18n:如何不翻译管理网站? [英] Django i18n: how to not translate the admin site?
本文介绍了Django i18n:如何不翻译管理网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几种语言的应用程序,但我想保持管理员网站始终是英文。
最好的方式是什么?
I have an application in several languages but I would like to keepthe admin site always in english. What is the best way to do this?
提前感谢。
推荐答案
考虑使用覆盖某些URL的区域设置的中间件。这是一个很大的例子:
Consider using middleware that overrides the locale for certain URLs. Hhere's a rough example:
from django.conf import settings
from django.utils.translation import activate
import re
class ForceInEnglish(object):
def process_request(self, request):
if re.match(".*admin/", request.path):
activate("en")
else:
activate(settings.LANGUAGE_CODE)
这只是一个实现的想法。
This is just an idea of implementation.
这篇关于Django i18n:如何不翻译管理网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文