1 language.inc language_negotiation_get_switch_links($type, $path)

Returns the language switch links for the given language.


$type: The language negotiation type.

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

Return value

object|bool: FALSE if no links. Otherwise, an object containing a keyed array of links ready to be themed, and the provider ID.

Related topics


core/includes/language.inc, line 253
Language Negotiation API.


function language_negotiation_get_switch_links($type, $path) {
  $links = FALSE;
  $negotiation_order = language_negotiation_order($type);
  $negotiation_info = language_negotiation_info();
  foreach ($negotiation_order as $id) {
    $provider = $negotiation_info[$id];
    if (isset($provider['callbacks']['switcher'])) {
      if (isset($provider['file'])) {
        require_once BACKDROP_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']['lang'] = $langcode;
        $result[$langcode]['attributes']['xml:lang'] = $langcode;

      if (!empty($result)) {
        // Allow modules to provide translations for specific links.
        backdrop_alter('language_switch_links', $result, $type, $path);
        $links = (object) array('links' => $result, 'provider' => $id);

  return $links;