Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 529316b.patch | 5.61 KB | jhodgdon |
#1 | 529316.patch | 5.91 KB | jhodgdon |
Comments
Comment #1
jhodgdonGood 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.
Comment #2
jhodgdonJust 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!!
Comment #4
jhodgdonHere's a new patch that should apply to the new code.
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #6
jhodgdonThis should probably also be ported to Drupal 6.
Comment #7
jhodgdonI 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
Comment #8
jhodgdon