如何在Django中禁用默认翻译值? [英] How do I disable default translation values in Django?

查看:77
本文介绍了如何在Django中禁用默认翻译值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些标签无需设置* .po文件即可为我翻译单词.

Some Tags give me translated Words without setting up the *.po file.

{% trans "groups" %}
{% trans "users" %}

不幸的是,在创建* .po文件并运行时它们不会被覆盖:

Unfortunately they won't be overridden when creating the *.po file and running:

django-admin.py compilemessages

那么如何摆脱默认翻译呢?我希望在项目级别上使用一种解决方案,因为我不想修改Django核心文件.

So how do I get rid of the default translations ? I would prefer a solution on project level, because I don't want to modify Django core files.

推荐答案

有几种方法可以覆盖它

  • 在设置文件的LOCALE_PATHS中设置您的语言环境路径,这使您的翻译具有更高的优先级.
  • 将msgid更改为与Django使用的msgid不同.然后提供将要使用的语言的翻译. msgid可以是任何东西加上基本字符串,只要它是唯一且易于翻译的,例如名称空间前缀:{% trans "my:groups" %}
  • Django1.3 +的上下文标记 ,则它看起来像{% trans "groups" context "my" %}
  • set your locale path in LOCALE_PATHS in settings file, this gives your translations higher priority.
  • change the msgid to be different from those used by Django. Then provide translations for languages which will be used. The msgid could be anything plus base string as long as its unique and translator-friendly, for example a namespace prefix: {% trans "my:groups" %}
  • Contextual markers for Django1.3+ , then it looks like {% trans "groups" context "my" %}

这篇关于如何在Django中禁用默认翻译值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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