简体   繁体   中英

django translating variable by name instead of content

I would like to use django i18n system for translating content of my website.

One of this purpuse would be <meta keywords="word1, word2"> tag. At the moment I am translating "word1, word2" string but if I change it the rest of translations won't work.

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. 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 ?

Use placeholder text and create a en.po file with only that one translation containing the values. 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.

<meta keywords={% trans "META KEYWORDS" %} />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM