tags:

views:

17

answers:

1

I want to wrap a word in <strong> tags. Is it correct to do that right in the t() call, or am I supposed to do it some other way?

$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>';

Also, what about just dropped variables directly into t(), like this?

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

Both your questions are answered in the Drupal API documentation at http://api.drupal.org/api/function/t/6. A short summary:

You can wrap a word in html tags if you really must. Quote:

HTML markup within translation strings is allowed, but should be avoided if possible.

It is not allowed to drop variables into t() like you do in your code snippet. Quote:

Because t() is designed for handling code-based strings, in almost all cases, the actual string and not a variable must be passed through t().

marcvangend