禁用Django中特定应用的本地化 [英] Disabling localization for specific apps in Django

查看:54
本文介绍了禁用Django中特定应用的本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在Django设置中禁用特定应用的本地化?

Is there a way to disable localization for specific apps in settings for Django?

有两个可能的原因:

  • 在管理员应用程序(例如contrib/admin)中关闭本地化,因为管理员更喜欢使用英语而不是本地语言.

  • Switch off localization in admin apps eg contrib/admin because admins would prefer to use English rather than the local language.

某些应用默认翻译确实很糟糕且令人困惑,我们希望在开发过程中不要使用它们,直到我们自己进行适当的翻译为止.

Some app default translations are really bad and confusing, and we would like to keep them off during development until we get to doing our own proper translation.

我知道我们也许可以删除翻译文件或其他黑客工具,但是当我们进行频繁升级时,将其设置在设置中会更加方便.

I know we can just delete the translation files or other hacks maybe, but having this in settings is more convenient when we're doing frequent upgrades.

致谢.

推荐答案

没有这样的设置来禁用特定应用程序的翻译.

There is no such setting to disable translation for specific apps.

关于您的第一个用例,使用自定义中间件可以轻松实现使用另一种语言的管理员,请查看以下代码段:

Regarding your first use-case, having admin in another language is easily achived with custom middleware, check this snippet:

http://source.mihelac.org /2009/11/12/django-set-language-for-admin/

如果第三方应用程序的网址方案很简单,也许您可​​以使用相同的方法为其设置不同的(默认)语言.

If url scheme of 3rd party apps are simple, maybe you can use same approach to set different (default) language for them.

这篇关于禁用Django中特定应用的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆