[英]django translating variable by name instead of content
I would like to use django i18n system for translating content of my website. 我想使用django i18n系统翻译我的网站内容。
One of this purpuse would be <meta keywords="word1, word2">
tag. 这个目的之一就是
<meta keywords="word1, word2">
标签。 At the moment I am translating "word1, word2"
string but if I change it the rest of translations won't work. 目前,我正在翻译
"word1, word2"
字符串,但是如果更改它,其余的翻译将无法正常工作。
The best would be just setting the variable and saying the translation system "Use english version of the content of this variable". 最好的办法就是设置变量并说翻译系统“使用该变量内容的英文版本”。
I would like to avoid setting this in the database as this can be specified in the template or other html/python file. 我想避免在数据库中进行设置,因为可以在模板或其他html / python文件中指定它。 I'd like to avoid the additional database/cache hit.
我想避免额外的数据库/缓存命中。
Is there any way of displaying different language versions of variable - not the content ? 有什么方法可以显示变量的不同语言版本-而不是内容?
I know this can be done by including template with {% if LANGUAGE_CODE == "xx" %}
conditions but maybe there is the other way ? 我知道可以通过在
{% if LANGUAGE_CODE == "xx" %}
条件下包含模板来完成此操作,但也许还有其他方法吗?
Use placeholder text and create a en.po
file with only that one translation containing the values. 使用占位符文本并创建一个
en.po
文件,其中只有一个包含值的翻译。 Note that you will then be responsible for making the translators aware of the English content instead of it being contained in their corresponding .po file. 请注意,您将负责使翻译人员知道英语内容,而不是将其包含在相应的.po文件中。
<meta keywords={% trans "META KEYWORDS" %} />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.