Implements hook_menu_alter().
function translation_entity_menu_alter(array &$items) {
// Check that the declared menu base paths are actually valid.
foreach (entity_get_info() as $entity_type => $info) {
if (translation_entity_enabled($entity_type)) {
$path = $info['menu_base_path'];
// If the base path is not defined we cannot provide the translation UI
// for this entity type. In some cases the actual base path might not have
// a menu loader associated, hence we need to check also for the plain "%"
// variant. See for instance comment_menu().
if (!isset($items[$path]) && !isset($items["{$path}/edit"]) && !isset($items[_translation_entity_menu_strip_loaders($path)])) {
unset($items["{$path}/translations"], $items["{$path}/translations/add/%language/%language"], $items["{$path}/translations/delete/%language"]);
$t_args = array(
'@entity_type' => isset($info['label']) ? $info['label'] : $entity_type,
);
watchdog('entity translation', 'The entities of type @entity_type do not define a valid base path: it will not be possible to translate them.', $t_args, WATCHDOG_WARNING);
}
else {
$entity_position = count(explode('/', $path)) - 1;
$edit_path = $info['menu_edit_path'];
if (isset($items[$edit_path])) {
// If the edit path is a default local task we need to find the parent
// item.
$edit_path_split = explode('/', $edit_path);
do {
$entity_form_item =& $items[implode('/', $edit_path_split)];
array_pop($edit_path_split);
} while (!empty($entity_form_item['type']) && $entity_form_item['type'] == MENU_DEFAULT_LOCAL_TASK);
// Make the "Translate" tab follow the "Edit" one when possibile.
if (isset($entity_form_item['weight'])) {
$items["{$path}/translations"]['weight'] = $entity_form_item['weight'] + 0.01;
}
}
}
}
}
}