You are here

function language_negotiation_get_switch_links in Drupal 7

Returns the language switch links for the given language.

Parameters

$type: The language negotiation type.

$path: The internal path the switch links will be relative to.

Return value

A keyed array of links ready to be themed.

Related topics

3 calls to language_negotiation_get_switch_links()
locale_block_view in modules/locale/locale.module
Implements hook_block_view().
translation_node_overview in modules/translation/translation.pages.inc
Page callback: Displays a list of a node's translations.
translation_node_view in modules/translation/translation.module
Implements hook_node_view().

File

includes/language.inc, line 279
Language Negotiation API.

Code

function language_negotiation_get_switch_links($type, $path) {
  $links = FALSE;
  $negotiation = variable_get("language_negotiation_{$type}", array());

  // Only get the languages if we have more than one.
  if (count(language_list()) >= 2) {
    $language = language_initialize($type);
  }
  foreach ($negotiation as $id => $provider) {
    if (isset($provider['callbacks']['switcher'])) {
      if (isset($provider['file'])) {
        require_once DRUPAL_ROOT . '/' . $provider['file'];
      }
      $callback = $provider['callbacks']['switcher'];
      $result = $callback($type, $path);

      // Add support for WCAG 2.0's Language of Parts to add language identifiers.
      // http://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html
      foreach ($result as $langcode => $link) {
        $result[$langcode]['attributes']['xml:lang'] = $langcode;
      }
      if (!empty($result)) {

        // Allow modules to provide translations for specific links.
        drupal_alter('language_switch_links', $result, $type, $path);
        $links = (object) array(
          'links' => $result,
          'provider' => $id,
        );
        break;
      }
    }
  }
  return $links;
}