function language_url_rewrite

6.x language.inc language_url_rewrite(&$path, &$options)

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

1 call to language_url_rewrite()
url in drupal-6.x/includes/common.inc
Generates an internal or external URL.
1 string reference to 'language_url_rewrite'
url in drupal-6.x/includes/common.inc
Generates an internal or external URL.

File

drupal-6.x/includes/language.inc, line 104
Multiple language handling functionality.

Code

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

  // Only modify relative (insite) URLs.
  if (empty($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;
    }
  }
}