You are here

function i18n_menu in Internationalization 5.2

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_menu()
  2. 5 i18n.module \i18n_menu()
  3. 6 i18n.module \i18n_menu()
  4. 7 i18n.module \i18n_menu()

Implementation of hook_menu(). Modify rewriting conditions when viewing specific nodes

File

./i18n.module, line 132
Internationalization (i18n) module

Code

function i18n_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/i18n',
      'title' => t('Multilingual system'),
      'description' => t('Configure multilingual content and translation.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'i18n_admin_settings',
      ),
      'access' => user_access('administer site configuration'),
    );
    $items[] = array(
      'path' => 'admin/settings/i18n/main',
      'title' => t('Internationalization'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/i18n/language',
      'title' => t('Manage languages'),
      'description' => t('Configure languages.'),
      'callback' => 'locale_admin_manage',
      'type' => MENU_LOCAL_TASK,
    );
  }
  else {
    if (arg(0) == 'node') {
      if (isset($_POST['language']) && $_POST['language']) {
        $language = $_POST['language'];
      }
      elseif (is_numeric(arg(1)) && ($node = node_load(arg(1)))) {

        // Node language when loading specific nodes
        $language = $node->language;
      }
      if ($language) {
        i18n_selection_mode('node', db_escape_string($language));
      }
    }
    elseif (arg(0) == 'admin' && arg(0) == 'content' && user_access('administer all languages')) {

      // No restrictions for administration pages
      i18n_selection_mode('off');
    }
  }
  return $items;
}