How do I disable default translation values in Django?

ε祈祈猫儿з 提交于 2020-01-24 10:05:39

问题


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

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

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

django-admin.py compilemessages

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.


回答1:


There are several ways to override it

  • 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" %}



回答2:


I made more simpler. Instead of setting language like en,fr,ru and else, i add prefix 't_', so i'm using po from dirs like t_en,t_ru,t_fr



来源:https://stackoverflow.com/questions/9961411/how-do-i-disable-default-translation-values-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!