type) && variable_get('language_content_type_'. $form['#node']->type, 0)) && !isset($form['#node']->nid)) { $form['language'] = array( '#type' => 'value', '#value' => '', ); } } } /** * Implementation of hook_init */ function preserve_language_init() { // This is to fix http://drupal.org/node/283839 though will have side effects. if (module_exists('i18n') && variable_get('preserve_language_selection', 1) == 1 && arg(0) == 'node') { if (is_numeric(arg(1)) && ($node = node_load(arg(1))) && $node->language ) { i18n_selection_mode('off'); } } } /** * Implementation of hook_link_alter */ function preserve_language_link_alter(&$links, $node) { if (variable_get('preserve_language_on', 1) == 0) { return; } global $language; foreach ($links as $name => $link) { if (strncmp($name, 'node_translation_', strlen('node_translation_')) === 0) { $links[$name]['language'] = $language; } } } /** * Implementation of hook_menu(). */ function preserve_language_menu() { $items = array(); // Admin page $items['admin/settings/preserve_language'] = array( 'title' => 'Preserve language', 'description' => 'Settings for preserve language', 'page callback' => 'drupal_get_form', 'page arguments' => array('_preserve_language_admin'), 'access arguments' => array('administer preserve language'), 'type' => MENU_NORMAL_ITEM, 'file' => 'preserve_language.admin.inc', ); return $items; } /** * Implementation of hook_block(). * Displays a language switcher that does not call translation_link_alter * (and thus stops i18n from messing with our paths!) */ function preserve_language_block($op = 'list', $delta = 0) { if (!variable_get('preserve_language_block', 1)) { return array(); } if ($op == 'list') { $block[0]['info'] = t('Interface language switcher'); // Not worth caching. $block[0]['cache'] = BLOCK_NO_CACHE; return $block; } // Only show if we have at least two languages and language dependent // web addresses, so we can actually link to other language versions. elseif ($op == 'view' && variable_get('language_count', 1) > 1 && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) { $languages = language_list('enabled'); $links = array(); foreach ($languages[1] as $language) { $links[$language->language] = array( 'href' => $_GET['q'], 'title' => $language->native, 'language' => $language, 'attributes' => array('class' => 'language-link'), ); } $block['subject'] = t('Interface language'); $block['content'] = theme('links', $links, array()); return $block; } }