代码之家  ›  专栏  ›  技术社区  ›  JoseMarmolejos

更多的德鲁帕尔语态:获取分类术语的翻译描述

  •  0
  • JoseMarmolejos  · 技术社区  · 14 年前

    我正在做一个简单的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 }?>
    

    编辑添加:我的默认语言不是英语,我默认西班牙语和英语作为第二个选项。

    2 回复  |  直到 14 年前
        1
  •  1
  •   Pierre Buyle    14 年前

    如果您正在使用 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;?>
    
        2
  •  1
  •   dusan    14 年前

    尝试呼叫 t() :

    <div class="info"><?php echo trim_description(t($terms[$index]->description), 10) ?></div>