On this page
function language_url_split_prefix
language_url_split_prefix($path, $languages)
Splits the given path into prefix and actual path.
Parse the given path and return the language object identified by the prefix and the actual path.
Parameters
$path: The path to split.
$languages: An array of valid languages.
Return value
An array composed of:
- A language object corresponding to the identified prefix on success, FALSE otherwise.
- The path without the prefix on success, the given path otherwise.
Related topics
File
- includes/language.inc, line 530
- Language Negotiation API.
Code
function language_url_split_prefix($path, $languages) {
$args = empty($path) ? array() : explode('/', $path);
$prefix = array_shift($args);
// Search prefix within enabled languages.
foreach ($languages as $language) {
if (!empty($language->prefix) && $language->prefix == $prefix) {
// Rebuild $path with the language removed.
return array($language, implode('/', $args));
}
}
return array(FALSE, $path);
}
© 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/includes!language.inc/function/language_url_split_prefix/7.x