Hi,
Just noticed in Drupal 6.15 that menu items for user categories, those that generate secondary tabs, cannot be translated. The problem is that these menu items use check_plain for the title callback, so t() is never involved.
Here's the code in user.module, user_menu() that build these items:
$items['user/%user_category/edit/'. $category['name']] = array(
'title callback' => 'check_plain', // This is the problem !!!
'title arguments' => array($category['title']),
'page callback' => 'user_edit',
'page arguments' => array(1, 3),
'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access',
'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1),
'type' => MENU_LOCAL_TASK,
'weight' => $category['weight'],
'load arguments' => array('%map', '%index'),
'tab_parent' => 'user/%/edit',
'file' => 'user.pages.inc',
);
Instead, I think it could be like this:
$items['user/%user_category/edit/'. $category['name']] = array(
'title callback' => '_user_sanitize_category', // Use a different title callback !!!
'title arguments' => array($category['title']),
'page callback' => 'user_edit',
'page arguments' => array(1, 3),
'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access',
'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1),
'type' => MENU_LOCAL_TASK,
'weight' => $category['weight'],
'load arguments' => array('%map', '%index'),
'tab_parent' => 'user/%/edit',
'file' => 'user.pages.inc',
);
And then, add the following function somewhere in user.module:
function _user_sanitize_category($title) {
return check_plain(t($title));
}
Comments
Comment #1
markus_petrux commentedIn the meantime, I'm using the following snippet on a custom module that also does the job:
Comment #2
japanitrat commentedStill an issue
Comment #3
japanitrat commentedOr not?
Comment #4
markus_petrux commentedThis is still an issue. Here' a patch.
Comment #6
markus_petrux commentedRe-rolled without -p option.
Comment #8
markus_petrux commentedfailed? Well, I give up, sorry.
Comment #9
tajabosc commentedHello,
I'm also reporting this issue in drupal 6.16, with menu items generated by simplenews an content profile modules not translatable with "translate interface".
Comment #10
markus_petrux commentedIt seems last patch failed because "Ensure the patch applies to the lastest checkotu of the code-base.". AFAICT, this patch and the previous one are the same, so I do not know what else to do if the test fails. I'm unable to understand the log.
Here's an updated patch against a just checked out D6 code base.
Comment #11
Ian Ward commentedI've hit this issue too. The patch seems ok. Why is it ignored by the test bot?
Comment #12
damien tournoud commentedAs any user-input, those category names cannot be translated in Drupal 6; this is by design.
Comment #13
markus_petrux commentedSorry for the delay. :(
It seems to me this is as "user input" as a content type name.
Please, close the issue for a different reason, but not that one.