我正在做一个简单的for循环,遍历给定词汇表中的术语,这些术语都有默认语言和附加语言的描述。问题是,无论哪种语言是活动的,$term->description都总是返回默认的语言版本,所以我猜我在这里遗漏了一些东西,因为我猜测(显然是错误的)这个字段将由活动的语言版本填充。下面是我使用的一小段代码:
<?php $terms = taxonomy_get_tree(5);
for ($index = 0; $index < count($terms); $index++) {?>
...
<div class="info"><?php echo trim_description($terms[$index]->description, 10) ?></div>
<div class="more-info"><a href="<?php print url(taxonomy_term_path($terms[$index])); ?>">More details</a></div>
</div>
<?php }?>编辑后添加:我的默认语言不是英语,默认情况下我使用西班牙语,第二个选项是英语。
发布于 2010-06-21 14:27:53
如果您使用的是Taxonomy translation模块,则应该使用i18ntaxonomy_translate_terms()来获取术语的翻译。
<?php
global $language
$terms = i18ntaxonomy_translate_terms(taxonomy_get_tree(5), $language->language));
for ($index = 0; $index < count($terms); $index++): ?>
<div>
...
<div class="info"><?php echo trim_description($terms[$index]->description, 10) ?></div>
<div class="more-info"><a href="<?php print url(taxonomy_term_path($terms[$index])); ?>">More details</a></div>
</div>
<?php endfor;?>发布于 2010-06-19 01:57:18
尝试调用t()
<div class="info"><?php echo trim_description(t($terms[$index]->description), 10) ?></div>https://stackoverflow.com/questions/3071691
复制相似问题