【问题标题】:Translate a Field's Label in a Drupal Content Type翻译 Drupal 内容类型中的字段标签
【发布时间】:2010-02-24 12:32:10
【问题描述】:

我正在使用我的 Drupal 6 内容类型尝试 i18n,并且字段值可以正常翻译,但字段标签不能。

有没有办法翻译这个?

【问题讨论】:

  • 你试过翻译界面了吗?

标签: drupal drupal-6 internationalization cck


【解决方案1】:

很抱歉重新打开此线程,如果有人来到这里寻找为 Drupal 7 翻译字段标签的方法,请阅读下文。

在 Drupal 7 中,引入了核心函数template_preprocess_field()。在我们的 template.php 文件中使用它,我们可以通过 t() 函数传递每个字段标签。

/**
 * Implements template_preprocess_field().
 */
function THEMENAME_preprocess_field(&$vars, $hook) {

  // Check to make sure there's a label and it's visible.
  if(isset($vars['label']) && $vars['label_hidden'] === FALSE)
  {
     $vars['label'] = t($vars['label']);
  }

}

【讨论】:

【解决方案2】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多