2010-01-04 50 views
0

我想在<strong>標籤中包裝一個詞。在t()調用中正確地做到這一點是正確的,還是我應該以其他方式做到這一點?Drupal:錯誤地使用t()?

$help = '<p>' . t("Does this sample data look right for node type %node_type? If not, use your browser's <strong>back</strong> button to fix it on the previous page.", array('%node_type' => $_SESSION[NODE_TYPE_KEY])) . '</p>'; 

另外,剛剛將變量直接放入t()這樣呢?

foreach ($term_info['term_fields'] as $vocab) { 
     $options[$vocab] = t($vocab); // TODO: incorrect use of t()? 
    } 

回答

0

這兩個問題都可以在Drupal API文檔http://api.drupal.org/api/function/t/6上得到解答。簡短摘要:

如果您確實需要,您可以在html標籤中包裝一個單詞。報價:

翻譯字符串 內的HTML標記是允許的,但如果 應儘可能避免。

這是允許下降到變量T()就像你在你的代碼片段做。報價:

由於T()是專爲處理 基於代碼的字符串,在幾乎所有 的情況下,實際的字符串,而不是一個 變量必須到T通過()。