- 🇺🇸United States smustgrave
As there hasn't been movement on 12 years going to close out for now.
If still a valid feature request please reopen and update the issue summary for how this could apply to D10.
Thanks!
hi,
Im working on a project and implemented a small module that redirect language switcher link to a translation page not found - in case of a node that doesn't have translation.
in the page callback it shows links to the previous page and to the front page in all available languages
what do you think?
is this should be a part of the locale module? or part of i18n? or a separated contrib module?
here is the code:
function MODULENAME_translation_link_alter(&$links, $path) {
global $language;
//take care of node that don't have translations
//inspired from i18n_translation_link_alter
if ((preg_match("!^node/([0-9]+)(/.+|)$!", $path, $matches)) && ($node = node_load((int)$matches[1])) && empty($node->tnid)) {
$languages = language_list();
foreach ($links as $langcode => $link) {
if ($langcode != $language->language) {
$links[$langcode]['href'] = "translation_not_found";
}
}
}
}
and the page callback is something like this
function translation_not_found() {
drupal_set_header('HTTP/1.1 404 Not Found');
watchdog('translation page not found', 'called from '.check_plain($_SERVER['HTTP_REFERER']), NULL, WATCHDOG_NOTICE);
$output = '';
$languages = language_list('enabled');
foreach ($languages[1] as $langname) {
$output .= '<div id="desc-'.$langname->language.'">';
$output .= '<h2>'. $langname->native .'</h2>';
$output .= '<h3>'. t('Currently this page does not have translation', array(), $langname->language) .'</h3>';
$output .= '<h4>'. t('Actions', array(), $langname->language) .'</h4>';
$links = array(
'homepage' => array('title' => t('Go to Gloria home-page', array(), $langname->language), 'href' => '<front>', 'language' => $langname),
'prev' => array('title' => t('Go to previous page', array(), $langname->language), 'href' => $_SERVER['HTTP_REFERER']),
);
$output .= theme('links', $links);
$output .= '</div>';
}
return $output;
}
Im thinking of integration drupal_alter() so other pages that are not nodes will have the ability to hook into this.
i also thinking maybe to make the page callback themeable (using a theme function) so developers could change its appearance.
the page is called fro, a hook_menu function
functionMODULENAME_menu() {
$items = array();
$items['translation_not_found'] = array(
'title' => 'Tarnslation Not Found',
'page callback' => 'translation_not_found',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
As there hasn't been movement on 12 years going to close out for now.
If still a valid feature request please reopen and update the issue summary for how this could apply to D10.
Thanks!