How to disable default translation values ​​in Django?

Some tags give me word translation without setting up the * .po file.

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


Unfortunately, they will not be overridden when the * .po file is created and run: compilemessages


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


source to share

2 answers

There are several ways to override it

  • set your language path to LOCALE_PATHS in the preferences file, this will give your translations a higher priority.
  • Modify the file which is different from the one Django is using. Then specify the translations for the languages ​​to be used. Msgid can be anything plus the base string as long as it is unique and translatable, such as a namespace prefix:{% trans "my:groups" %}

  • Context markers for Django1.3 + , then it looks like{% trans "groups" context "my" %}



I made it easier. Instead of setting the language as en, fr, ru and else, I add the 't_' prefix, so I use po from dirs like t_en, t_ru, t_fr



All Articles