We have built and manage an existing multilingual site at www.debgroup.com/en but we are currently working on an update that will add in a few extra languages. This includes regionalised sites for Canada (French) and Belgium (Dutch). I proposed to use path prefixes 'ca-fr' and 'be-nl' but I have been asked to look in to the feasibility of using a "multipart prefix" like 'ca/fr' that contains a forward slash (like this Apple website: http://www.apple.com/ca/fr/).
It is possible to enter the prefix 'ca/fr' as a custom language in to the interface at /admin/settings/language/add but I get a page not found as soon as I switch to that language.
I looked at includes/language.inc and see that the root of the problem lies with the language_initialize() function that takes the URL and explodes it in to separate arguments on the forward slash - hence breaking up the prefix and not being able to find the right page.
Around line 35 of includes/language.inc:
case LANGUAGE_NEGOTIATION_PATH:
// $_GET['q'] might not be available at this time, because
// path initialization runs after the language bootstrap phase.
$args = isset($_GET['q']) ? explode('/', $_GET['q']) : array();
$prefix = array_shift($args);
// Search prefix within enabled languages.
foreach ($languages as $language) {
if (!empty($language->prefix) && $language->prefix == $prefix) {
// Rebuild $GET['q'] with the language removed.
$_GET['q'] = implode('/', $args);
return $language;
}
}
Does any one have any experience with working with multilingual sites with prefixes like this? Any advice to offer?
Thanks
Paul
Comments
I need the same functionality
I need the same functionality as described above. Should this be moved to a support request in the core Drupal issue queue?
If you need a workaround and don't mind editing the core, this code can be utilized. It keeps the default behavior for non-slash languages but adds a second check to see if the first two arguments together match the language prefix.
language.inc - line 35
Without deviation from the norm, progress is not possible. - Frank Zappa