How to use t() function for a text with anchor links? I have a text that I must show in 5 languages. I am using t() for that. The text is:


  In case of any issues, please Contact Us for assistance.


I want the phrase "Contact Us" to be a link. So this is what I have done:

$text = t('In case of any issues, please ')."&lt;a href="link/to/path"&gt;".t('Contact Us')."&lt;/a&gt;".t('for assistance');


I suspect that this might not be the correct way to do this as this will break the translation. I fear that the sentence will not be translated as a whole but in parts.

Am I right?

And if I am, what could be the correct way to do it?
You're absolutely correct; you should never concatenate strings with t(), the whole point is that it uses placeholders so you don't have to. Specifically:

// DO NOT DO THESE THINGS
$BAD_EXTERNAL_LINK = t('Look at Drupal documentation at !handbook.', array('!handbook' =&gt; '&lt;a href="http://drupal.org/handbooks"&gt;'. t('the Drupal Handbooks') .'&lt;/a&gt;'));

$ANOTHER_BAD_EXTERNAL_LINK = t('Look at Drupal documentation at &lt;a href="http://drupal.org/handbooks"&gt;the Drupal Handbooks&lt;/a&gt;.');

$BAD_INTERNAL_LINK = t('To get an overview of your administration options, go to !administer in the main menu.', array('!administer' =&gt; l(t('the Administer screen'), 'admin'));


Instead of those you should use the following:

// Do this instead.
$external_link = t('Look at Drupal documentation at &lt;a href="@drupal-handbook"&gt;the Drupal Handbooks&lt;/a&gt;.', array('@drupal-handbook' =&gt; 'http://drupal.org/handbooks'));

$internal_link = t('To get an overview of your administration options, go to &lt;a href="@administer-page"&gt;the Administer screen&lt;/a&gt; in the main menu.', array('@administer-page' =&gt; url('admin')));


See Dynamic or static links and HTML in translatable strings for full details.