Return value example for hook_help at http://api.drupal.org/api/function/hook_help reads:

$output .= 'A role defines a group of users that have certain privileges as defined in %permission.'; 
$output = t($output, array('%permission' => l(t('user permissions'), 'admin/user/permission')));

Which will not output the link in the text correctly. In accordance with the documentation for t(), it should read:

$output .= 'A role defines a group of users that have certain privileges as defined in !permission.'; 
$output = t($output, array('!permission' => l(t('user permissions'), 'admin/user/permission')));

In order for the link to be rendered as markup rather than plain text.

CommentFileSizeAuthor
#4 529316b.patch5.61 KBjhodgdon
#1 529316.patch5.91 KBjhodgdon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Version: 6.13 » 7.x-dev
Status: Active » Needs review
FileSize
5.91 KB

Good point, but actually I don't think that example is very good at all, and I'm not sure an example of how to use t() is really needed there, since the body of hook_help() below has examples.

And there are some other issues with the doc for that hook, which hasn't been modified substantially since Drupal 4.6 at least! Here's a try at cleaning it up.

jhodgdon’s picture

Just as another note, if someone thinks an example is useful in the return value, it shouldn't have $object being passed into t(), but rather the string directly, as the translation template extractor will not work correctly with a variable passed into t(). On the whole, that example was very bad!!

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
5.61 KB

Here's a new patch that should apply to the new code.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)

This should probably also be ported to Drupal 6.

jhodgdon’s picture

I went ahead and ported the patch to Drupal 6 and checked it in (it's in the contrib repository). See http://drupal.org/cvs?commit=268578

jhodgdon’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.