{% i18ninclude "faq/question1.html" "en" %}
1
1
テキストの小さな部分には、django standart \ {%trans%}タグを使用します
FAQ、用語、その他の静的ページなどの大きなテキストをどうするか
2 Answer
6
使用できるhttp://docs.djangoproject.com/en/dev/topics/i18n/#in-template-code[`{% blocktrans%} `]テンプレートタグがあります。
また、現在の言語に基づいたアナザーテンプレートを含む簡単なテンプレートタグを自分で作成することもできます。
{% i18ninclude "faq/question1.html" "en" %}
`faq / question1.en.html`を含めます。 これがコードです:
import os from django import template register = template.Library() @register.simpletag def i18ninclude(template_name, language): template_name, extension = os.path.splitext(template_name) template_name = '%s.%s%s' % (template_name, language, extension) return template.loader.render_to_string(template_name)
これをアプリのtemplatetagライブラリに入れます。 また、まだ行っていない場合は、http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ [カスタムテンプレートタグに関するドキュメント]を読むことをお勧めします。
2
django-better-chunksをご覧ください。 テンプレート内に静的HTMLのスニペットを挿入でき、i18nをサポートしています。
静的なページの場合、http://www.django-cms.org/ [django-cms]など、ある種のCMSを使用することをお勧めします。 また、i18n対応です。