function language_url_outbound_alter

Implements hook_url_outbound_alter().

Rewrite outbound URLs with language based prefixes.

4 string references to 'language_url_outbound_alter'
LanguageUrlRewritingTest::setUp in drupal/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
Sets up a Drupal site for running functional and integration tests.
LanguageUrlRewritingTest::testDomainNameNegotiationPort in drupal/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
Check URL rewriting when using a domain name and a non-standard port.
PathLanguageTest::testAliasTranslation in drupal/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
Test alias functionality through the admin interfaces.
TranslationTest::resetCaches in drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
Resets static caches to make the test code match the client-side behavior.

File

drupal/core/modules/language/language.module, line 793
Add language handling functionality to Drupal.

Code

function language_url_outbound_alter(&$path, &$options, $original_path) {

  // Only modify internal URLs.
  if (!$options['external'] && language_multilingual()) {
    static $drupal_static_fast;
    if (!isset($drupal_static_fast)) {
      $drupal_static_fast['callbacks'] =& drupal_static(__FUNCTION__);
    }
    $callbacks =& $drupal_static_fast['callbacks'];
    if (!isset($callbacks)) {
      $callbacks = array();
      include_once DRUPAL_ROOT . '/core/includes/language.inc';
      foreach (language_types_get_configurable() as $type) {

        // Get URL rewriter callbacks only from enabled language methods.
        $negotiation = variable_get("language_negotiation_{$type}", array());
        foreach ($negotiation as $method_id => $method) {
          if (isset($method['callbacks']['url_rewrite'])) {
            if (isset($method['file'])) {
              require_once DRUPAL_ROOT . '/' . $method['file'];
            }

            // Avoid duplicate callback entries.
            $callbacks[$method['callbacks']['url_rewrite']] = TRUE;
          }
        }
      }
      $callbacks = array_keys($callbacks);
    }

    // No language dependent path allowed in this mode.
    if (empty($callbacks)) {
      unset($options['language']);
      return;
    }
    foreach ($callbacks as $callback) {
      if (function_exists($callback)) {
        $callback($path, $options);
      }
    }
  }
}