You are here

function i18n_menu_item_get_language in Internationalization 7

Get language for menu item

1 call to i18n_menu_item_get_language()
i18n_menu_form_menu_edit_item_alter in i18n_menu/i18n_menu.module
Implements hook_form_FORM_ID_alter().

File

i18n_menu/i18n_menu.module, line 776
Internationalization (i18n) submodule: Menu translation.

Code

function i18n_menu_item_get_language($item) {
  if (isset($item['language'])) {
    return $item['language'];
  }
  else {
    $menu = menu_load($item['menu_name']);
    if (!isset($menu['i18n_mode'])) {
      return LANGUAGE_NONE;
    }
    switch ($menu['i18n_mode']) {
      case I18N_MODE_LANGUAGE:
        return $menu['language'];
      case I18N_MODE_NONE:
      case I18N_MODE_LOCALIZE:
        return LANGUAGE_NONE;
      default:
        if (!empty($item['mlid'])) {
          return db_select('menu_links', 'm')
            ->fields('m', array(
            'language',
          ))
            ->condition('mlid', $item['mlid'])
            ->execute()
            ->fetchField();
        }
        else {
          return LANGUAGE_NONE;
        }
    }
  }
}