function language_negotiation_get_switch_links

Returns the language switch links for the given language type.

Parameters

$type: The language 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

4 calls to language_negotiation_get_switch_links()
LanguageBlock::build in drupal/core/modules/language/lib/Drupal/language/Plugin/Block/LanguageBlock.php
Builds and returns the renderable array for this block plugin.
translation_node_overview in drupal/core/modules/translation/translation.pages.inc
Page callback: Displays a list of a node's translations.
translation_node_view in drupal/core/modules/translation/translation.module
Implements hook_node_view().
_translation_entity_get_switch_links in drupal/core/modules/translation_entity/translation_entity.pages.inc
Returns the localized links for the given path.

File

drupal/core/includes/language.inc, line 308
Language Negotiation API.

Code

function language_negotiation_get_switch_links($type, $path) {
  $links = FALSE;
  $negotiation = variable_get("language_negotiation_{$type}", array());
  foreach ($negotiation as $method_id => $method) {
    if (isset($method['callbacks']['language_switch'])) {
      if (isset($method['file'])) {
        require_once DRUPAL_ROOT . '/' . $method['file'];
      }
      $callback = $method['callbacks']['language_switch'];
      $result = $callback($type, $path);
      if (!empty($result)) {

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