On this page
function locale_url_outbound_alter
locale_url_outbound_alter(&$path, &$options, $original_path)
Implements hook_url_outbound_alter().
Rewrite outbound URLs with language based prefixes.
File
- modules/locale/locale.module, line 1058
- Add language handling functionality and enables the translation of the user interface to languages other than English.
Code
function locale_url_outbound_alter(&$path, &$options, $original_path) {
// Only modify internal URLs.
if (!$options['external'] && drupal_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 . '/includes/language.inc';
foreach (language_types_configurable() as $type) {
// Get URL rewriter callbacks only from enabled language providers.
$negotiation = variable_get("language_negotiation_$type", array());
foreach ($negotiation as $id => $provider) {
if (isset($provider['callbacks']['url_rewrite'])) {
if (isset($provider['file'])) {
require_once DRUPAL_ROOT . '/' . $provider['file'];
}
// Avoid duplicate callback entries.
$callbacks[$provider['callbacks']['url_rewrite']] = TRUE;
}
}
}
$callbacks = array_keys($callbacks);
}
foreach ($callbacks as $callback) {
$callback($path, $options);
}
// No language dependent path allowed in this mode.
if (empty($callbacks)) {
unset($options['language']);
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!locale!locale.module/function/locale_url_outbound_alter/7.x