【发布时间】:2016-12-19 22:41:17
【问题描述】:
所以我在我的自定义 drupal 8 问题中有以下问题,它在某种程度上与缓存冲突。它需要一些部分作为可翻译的字符串(好的)和来自后端服务的一些部分(不好)
我的模块数组:
return array(
'#theme' => 'block__vt_course_offer',
'#data' => $courseData,
'#cache' => [
'contexts' => ['languages'],
'tags' => $cacheTags,
]
);
我的模板的一部分
<!-- This works just perfect: -->{% trans %}Prüfungen{% endtrans %}
...
<div class="course-block__desc">
<!-- This dissplays only one language at the moment of cache build: -->
{{ course_type.short_description[language] | raw }}
</div>
启用缓存后,有没有办法以不同的语言为{{ course_type.short_description[language] | raw }} 提供不同的值?目前它使用第一次调用的语言,当缓存被清除时,这会导致英文网站上的德语内容,反之亦然。
非常感谢您的帮助!
【问题讨论】: