diff options
Diffstat (limited to 'includes/locale.inc')
-rw-r--r-- | includes/locale.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/includes/locale.inc b/includes/locale.inc index 75e534395..b36bcd9e9 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -321,11 +321,27 @@ function locale_language_switcher_session($type, $path) { * Rewrite URLs for the URL language provider. */ function locale_language_url_rewrite_url(&$path, &$options) { + static $drupal_static_fast; + if (!isset($drupal_static_fast)) { + $drupal_static_fast['languages'] = &drupal_static(__FUNCTION__); + } + $languages = &$drupal_static_fast['languages']; + + if (!isset($languages)) { + $languages = language_list('enabled'); + $languages = array_flip(array_keys($languages[1])); + } + // Language can be passed as an option, or we go for current URL language. if (!isset($options['language'])) { global $language_url; $options['language'] = $language_url; } + // We allow only enabled languages here. + elseif (!isset($languages[$options['language']->language])) { + unset($options['language']); + return; + } if (isset($options['language'])) { switch (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX)) { |