language_url_rewrite

Versions
6
language_url_rewrite(&$path, &$options)

Rewrite URL's with language based prefix. Parameters are the same as those of the url() function.

▾ 1 function calls language_url_rewrite()

url in includes/common.inc
Generate a URL from a Drupal menu path. Will also pass-through existing URLs.

Code

includes/language.inc, line 104

<?php
function language_url_rewrite(&$path, &$options) {
  global $language;

  // Only modify relative (insite) URLs.
  if (!$options['external']) {

    // Language can be passed as an option, or we go for current language.
    if (!isset($options['language'])) {
      $options['language'] = $language;
    }

    switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
      case LANGUAGE_NEGOTIATION_NONE:
        // No language dependent path allowed in this mode.
        unset($options['language']);
        break;

      case LANGUAGE_NEGOTIATION_DOMAIN:
        if ($options['language']->domain) {
          // Ask for an absolute URL with our modified base_url.
          $options['absolute'] = TRUE;
          $options['base_url'] = $options['language']->domain;
        }
        break;

      case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
        $default = language_default();
        if ($options['language']->language == $default->language) {
          break;
        }
        // Intentionally no break here.

      case LANGUAGE_NEGOTIATION_PATH:
        if (!empty($options['language']->prefix)) {
          $options['prefix'] = $options['language']->prefix .'/';
        }
        break;
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.