覆盖默认的Django翻译
我有一个模板:
{% trans "Log out" %}
由Django自动翻译为西班牙语,为终结式sesión。但是,我想将其翻译成为Cerrarsesión。
This is translated automatically by Django to Spanish as Terminar sesión. However I would like to translate it as Cerrar sesión.
我已经尝试将这个文字添加到.po文件,但是我得到错误说这个文字在我编译邮件时被重复。
I have tried to add this literal to the .po file, however I get an error saying this literal is duplicated when I compile the messages.
有没有办法更改/覆盖默认的Django翻译?
Is there a way to change/override default Django translations?
谢谢。
最简单的方法是收集在django.contrib.admin语言环境中找到的.po文件文件夹并重新编译它(您可以使用POEdit进行此操作)。
The easiest way is to collect the .po file found in the django.contrib.admin locale folder and re-compiling it (you can use POEdit for doing so).
您还可以将django.contrib.admin模板放在项目模板文件夹中(例如:yourproject / templates / admin / change_form.html)然后从项目根运行makemessages(尽管如果我是正确的,那么django 1.4 alpha不再支持)
You could also override the django.contrib.admin templates by putting them in your projects templates folder (for example: yourproject/templates/admin/change_form.html) then running makemessages from the project root (although this is no longer supported for django 1.4 alpha if i'm correct)
编辑: Robert Lujo的答案是干净的方法
edit: Robert Lujo's answer is the clean method