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

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

File

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

Code

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);
        break;
      }
    }
  }

  return $links;
}