Index: modules/aggregator/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.392 diff -u -p -r1.392 aggregator.module --- modules/aggregator/aggregator.module 17 Sep 2008 07:11:56 -0000 1.392 +++ modules/aggregator/aggregator.module 25 Sep 2008 08:04:53 -0000 @@ -269,10 +269,10 @@ function _aggregator_has_categories() { * Implementation of hook_perm(). */ function aggregator_perm() { - return array( + return user_localize_permissions(array( 'administer news feeds' => t('Add, edit or delete news feeds that are aggregated to your site.'), 'access news feeds' => t('View aggregated news feed items.'), - ); + )); } /** Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.309 diff -u -p -r1.309 block.module --- modules/block/block.module 21 Aug 2008 19:36:36 -0000 1.309 +++ modules/block/block.module 25 Sep 2008 08:04:53 -0000 @@ -104,10 +104,10 @@ function block_theme() { * Implementation of hook_perm(). */ function block_perm() { - return array( + return user_localize_permissions(array( 'administer blocks' => t('Select which blocks are displayed, and arrange them on the page.'), 'use PHP for block visibility' => t('Enter PHP code in the field for block visibility settings. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), - ); + )); } /** Index: modules/blogapi/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v retrieving revision 1.126 diff -u -p -r1.126 blogapi.module --- modules/blogapi/blogapi.module 17 Sep 2008 21:07:47 -0000 1.126 +++ modules/blogapi/blogapi.module 25 Sep 2008 08:04:53 -0000 @@ -24,9 +24,9 @@ function blogapi_help($path, $arg) { * Implementation of hook_perm(). */ function blogapi_perm() { - return array( + return user_localize_permissions(array( 'administer content with blog api' => t('Manage website content from external tools.'), - ); + )); } /** Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.468 diff -u -p -r1.468 book.module --- modules/book/book.module 17 Sep 2008 20:37:31 -0000 1.468 +++ modules/book/book.module 25 Sep 2008 08:04:53 -0000 @@ -40,12 +40,12 @@ function book_theme() { * Implementation of hook_perm(). */ function book_perm() { - return array( + return user_localize_permissions(array( 'administer book outlines' => t('Manage books through the administration panel.'), 'create new books' => t('Add new top-level books.'), 'add content to books' => t('Add new content and child pages to books.'), 'access printer-friendly version' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'), - ); + )); } /** Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.650 diff -u -p -r1.650 comment.module --- modules/comment/comment.module 17 Sep 2008 20:37:31 -0000 1.650 +++ modules/comment/comment.module 25 Sep 2008 08:04:54 -0000 @@ -240,12 +240,12 @@ function comment_node_type($op, $info) { * Implementation of hook_perm(). */ function comment_perm() { - return array( + return user_localize_permissions(array( 'administer comments' => t('Manage and approve comments, and configure comment administration settings.'), 'access comments' => t('View comments attached to content.'), 'post comments' => t('Add comments to content (approval required).'), 'post comments without approval' => t('Add comments to content (no approval required).'), - ); + )); } /** Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.109 diff -u -p -r1.109 contact.module --- modules/contact/contact.module 17 Sep 2008 20:37:32 -0000 1.109 +++ modules/contact/contact.module 25 Sep 2008 08:04:54 -0000 @@ -36,10 +36,10 @@ function contact_help($path, $arg) { * Implementation of hook_perm(). */ function contact_perm() { - return array( + return user_localize_permissions(array( 'administer site-wide contact form' => t('Configure site-wide contact form administration settings.'), 'access site-wide contact form' => t('Send feedback to administrators via e-mail using the site-wide contact form.'), - ); + )); } /** Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.227 diff -u -p -r1.227 filter.module --- modules/filter/filter.module 19 Sep 2008 07:53:59 -0000 1.227 +++ modules/filter/filter.module 25 Sep 2008 08:04:54 -0000 @@ -145,9 +145,9 @@ function filter_admin_format_title($form * Implementation of hook_perm(). */ function filter_perm() { - return array( + return user_localize_permissions(array( 'administer filters' => t('Manage input formats and filters, and select which roles may use them. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), - ); + )); } /** Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.464 diff -u -p -r1.464 forum.module --- modules/forum/forum.module 19 Sep 2008 20:25:02 -0000 1.464 +++ modules/forum/forum.module 25 Sep 2008 08:04:54 -0000 @@ -317,9 +317,9 @@ function forum_access($op, $node, $accou * Implementation of hook_perm(). */ function forum_perm() { - $perms = array( + $perms = user_localize_permissions(array( 'administer forums' => t('Manage forums and configure forum administration settings.'), - ); + )); $perms += node_list_permissions('forum'); return $perms; } Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.223 diff -u -p -r1.223 locale.module --- modules/locale/locale.module 20 Sep 2008 20:22:24 -0000 1.223 +++ modules/locale/locale.module 25 Sep 2008 08:04:54 -0000 @@ -195,10 +195,10 @@ function locale_inc_callback() { * Implementation of hook_perm(). */ function locale_perm() { - return array( + return user_localize_permissions(array( 'administer languages' => t('Manage the languages in which the website content and interface text may be displayed.'), 'translate interface' => t('Translate the text of the website interface.'), - ); + )); } /** Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.168 diff -u -p -r1.168 menu.module --- modules/menu/menu.module 15 Sep 2008 20:48:08 -0000 1.168 +++ modules/menu/menu.module 25 Sep 2008 08:04:54 -0000 @@ -37,9 +37,9 @@ function menu_help($path, $arg) { * Implementation of hook_perm(). */ function menu_perm() { - return array( + return user_localize_permissions(array( 'administer menu' => t('Manage menus and menu items.'), - ); + )); } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.977 diff -u -p -r1.977 node.module --- modules/node/node.module 17 Sep 2008 20:37:32 -0000 1.977 +++ modules/node/node.module 25 Sep 2008 08:04:54 -0000 @@ -1161,14 +1161,14 @@ function theme_node_log_message($log) { * Implementation of hook_perm(). */ function node_perm() { - $perms = array( + $perms = user_localize_permissions(array( 'administer content types' => t('Manage content types and content type administration settings.'), 'administer nodes' => t('Manage all website content, and bypass any content-related access control. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), 'access content' => t('View published content.'), 'view revisions' => t('View content revisions.'), 'revert revisions' => t('Replace content with an older revision.'), 'delete revisions' => t('Delete content revisions.'), - ); + )); foreach (node_get_types() as $type) { if ($type->module == 'node') { @@ -2871,11 +2871,11 @@ function node_list_permissions($type) { $type = check_plain($info->type); // Build standard list of node permissions for this type. - $perms["create $type content"] = t('Create new %type_name content.', array('%type_name' => $info->name)); - $perms["edit own $type content"] = t('Edit %type_name content created by the user.', array('%type_name' => $info->name)); - $perms["edit any $type content"] = t('Edit any %type_name content, regardless of its author.', array('%type_name' => $info->name)); - $perms["delete own $type content"] = t('Delete %type_name content created by the user.', array('%type_name' => $info->name)); - $perms["delete any $type content"] = t('Delete any %type_name content, regardless of its author.', array('%type_name' => $info->name)); + $perms["create $type content"] = array(t('create @type content', array('@type' => $info->type)), t('Create new %type_name content.', array('%type_name' => $info->name))); + $perms["edit own $type content"] = array(t('edit own @type content', array('@type' => $info->type)), t('Edit %type_name content created by the user.', array('%type_name' => $info->name))); + $perms["edit any $type content"] = array(t('edit any @type content', array('@type' => $info->type)), t('Edit any %type_name content, regardless of its author.', array('%type_name' => $info->name))); + $perms["delete own $type content"] = array(t('delete own @type content', array('@type' => $info->type)), t('Delete %type_name content created by the user.', array('%type_name' => $info->name))); + $perms["delete any $type content"] = array(t('delete any @type content', array('@type' => $info->type)), t('Delete any %type_name content, regardless of its author.', array('%type_name' => $info->name))); return $perms; } Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.145 diff -u -p -r1.145 path.module --- modules/path/path.module 17 Sep 2008 20:37:32 -0000 1.145 +++ modules/path/path.module 25 Sep 2008 08:04:54 -0000 @@ -203,10 +203,10 @@ function path_form_alter(&$form, $form_s * Implementation of hook_perm(). */ function path_perm() { - return array( + return user_localize_permissions(array( 'administer url aliases' => t('Manage URL aliases across the entire website.'), 'create url aliases' => t('Manage URL aliases on content.'), - ); + )); } /** Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.272 diff -u -p -r1.272 poll.module --- modules/poll/poll.module 17 Sep 2008 07:11:57 -0000 1.272 +++ modules/poll/poll.module 25 Sep 2008 08:04:54 -0000 @@ -55,11 +55,11 @@ function poll_theme() { */ function poll_perm() { $perms = node_list_permissions('poll'); - $perms += array( + $perms += user_localize_permissions(array( 'vote on polls' => t('Cast votes on polls.'), 'cancel own vote' => t('Retract and optionally change own votes.'), 'inspect all votes' => t('View voting results.'), - ); + )); return $perms; } Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.266 diff -u -p -r1.266 search.module --- modules/search/search.module 17 Sep 2008 20:37:32 -0000 1.266 +++ modules/search/search.module 25 Sep 2008 08:04:54 -0000 @@ -141,11 +141,11 @@ function search_theme() { * Implementation of hook_perm(). */ function search_perm() { - return array( + return user_localize_permissions(array( 'administer search' => t('Configure search administration settings.'), 'search content' => t('Search website content.'), 'use advanced search' => t('Limit search results with additional criteria, such as specific content types. Could have performance implications.'), - ); + )); } /** Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.15 diff -u -p -r1.15 simpletest.module --- modules/simpletest/simpletest.module 20 Sep 2008 20:22:24 -0000 1.15 +++ modules/simpletest/simpletest.module 25 Sep 2008 08:04:54 -0000 @@ -34,9 +34,9 @@ function simpletest_menu() { * Implementation of hook_perm(). */ function simpletest_perm() { - return array( + return user_localize_permissions(array( 'administer unit tests' => t('Manage and run automated testing. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), - ); + )); } /** Index: modules/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.283 diff -u -p -r1.283 statistics.module --- modules/statistics/statistics.module 17 Sep 2008 07:11:58 -0000 1.283 +++ modules/statistics/statistics.module 25 Sep 2008 08:04:54 -0000 @@ -83,10 +83,10 @@ function statistics_exit() { * Implementation of hook_perm(). */ function statistics_perm() { - return array( + return user_localize_permissions(array( 'access statistics' => t('View content access statistics.'), 'view post access counter' => t('View the total number of times a piece of content has been accessed.'), - ); + )); } /** Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.623 diff -u -p -r1.623 system.module --- modules/system/system.module 20 Sep 2008 03:49:24 -0000 1.623 +++ modules/system/system.module 25 Sep 2008 08:04:54 -0000 @@ -164,7 +164,7 @@ function system_theme() { * Implementation of hook_perm(). */ function system_perm() { - return array( + return user_localize_permissions(array( 'administer site configuration' => t('Configure site-wide settings such as module or theme administration settings.'), 'administer actions' => t('Manage the actions defined for your site.'), 'administer files' => t('Manage user-uploaded files.'), @@ -172,7 +172,7 @@ function system_perm() { 'access site reports' => t('View reports from system logs and other status information.'), 'select different theme' => t('Select a theme other than the default theme set by the site administrator.'), 'block IP addresses' => t('Block IP addresses from accessing your site.'), - ); + )); } /** Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.429 diff -u -p -r1.429 taxonomy.module --- modules/taxonomy/taxonomy.module 24 Sep 2008 18:42:00 -0000 1.429 +++ modules/taxonomy/taxonomy.module 25 Sep 2008 08:04:54 -0000 @@ -10,9 +10,9 @@ * Implementation of hook_perm(). */ function taxonomy_perm() { - return array( + return user_localize_permissions(array( 'administer taxonomy' => t('Manage taxonomy vocabularies and terms.'), - ); + )); } /** Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.29 diff -u -p -r1.29 translation.module --- modules/translation/translation.module 16 Aug 2008 21:36:57 -0000 1.29 +++ modules/translation/translation.module 25 Sep 2008 08:04:54 -0000 @@ -85,9 +85,9 @@ function _translation_tab_access($node) * Implementation of hook_perm(). */ function translation_perm() { - return array( + return user_localize_permissions(array( 'translate content' => t('Translate website content.'), - ); + )); } /** Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.206 diff -u -p -r1.206 upload.module --- modules/upload/upload.module 15 Sep 2008 09:28:50 -0000 1.206 +++ modules/upload/upload.module 25 Sep 2008 08:04:54 -0000 @@ -43,10 +43,10 @@ function upload_theme() { * Implementation of hook_perm(). */ function upload_perm() { - return array( + return user_localize_permissions(array( 'upload files' => t('Attach images and other files to content.'), 'view uploaded files' => t('View and download files attached to content.'), - ); + )); } /** Index: modules/user/user.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v retrieving revision 1.27 diff -u -p -r1.27 user.admin.inc --- modules/user/user.admin.inc 17 Sep 2008 20:37:32 -0000 1.27 +++ modules/user/user.admin.inc 25 Sep 2008 08:04:54 -0000 @@ -516,16 +516,15 @@ function user_admin_perm($form_state, $r '#markup' => $module, ); foreach ($permissions as $perm => $description) { - // Account for permissions lacking a description. - if (is_int($perm)) { - $perm = $description; - $description = NULL; + if (is_int($perm) || !array($description)) { + // Pre Drupal 7.x code, should not be there. + continue; } $options[$perm] = ''; $form['permission'][$perm] = array( '#type' => 'item', - '#markup' => t($perm), - '#description' => $hide_descriptions ? $description : NULL, + '#markup' => $description[0], + '#description' => $hide_descriptions ? $description[1] : NULL, ); foreach ($role_names as $rid => $name) { // Builds arrays for checked boxes for each role Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.924 diff -u -p -r1.924 user.module --- modules/user/user.module 21 Sep 2008 15:08:39 -0000 1.924 +++ modules/user/user.module 25 Sep 2008 08:04:54 -0000 @@ -570,12 +570,12 @@ function user_is_blocked($name) { * Implementation of hook_perm(). */ function user_perm() { - return array( + return user_localize_permissions(array( 'administer permissions' => t('Manage the permissions assigned to user roles. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))), 'administer users' => t('Manage or block users, and manage their role assignments.'), 'access user profiles' => t('View profiles of users on the site, which may contain personal information.'), 'change own username' => t('Select a different username.'), - ); + )); } /** @@ -2418,3 +2418,16 @@ function _user_forms(&$edit, $account, $ return empty($groups) ? FALSE : $groups; } + +/** + * Transform a simplified permission array to a localized one. + * + * Also serves as a marker for the contrib potx.module to find permission + * arrays and offer $perm keys from the array for translation. + */ +function user_localize_permissions($permissions) { + foreach ($permissions as $perm => $description) { + $permissions[$perm] = array(t($perm), $description); + } + return $permissions; +}