You are here

function purl_language_strip in Persistent URL 7

Same name and namespace in other branches
  1. 6 purl.module \purl_language_strip()

@todo is this still needed?? (Does language_init still modify $_GET['q'])

See also

http://drupal.org/update/modules/6/7#language_negotiation

File

./purl.module, line 147

Code

function purl_language_strip($path) {

  // Configured presentation language mode.
  $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);

  // Get a list of enabled languages.
  $languages = language_list('enabled');
  $languages = $languages[1];
  if (in_array($mode, array(
    LANGUAGE_NEGOTIATION_PATH_DEFAULT,
    LANGUAGE_NEGOTIATION_PATH,
  ))) {
    $args = explode('/', $path);
    $prefix = array_shift($args);

    // Search prefix within enabled languages.
    foreach ($languages as $language) {
      if (!empty($language->prefix) && $language->prefix == $prefix) {
        return implode('/', $args);
      }
    }
  }
  return $path;
}