Im trying to figure out a basic multi-language solution for a rather convoluted search engine website architecture and I was wondering if it was possible to have the main search result page templates, pull in different elements (like or sidebars or even individual divs) based on the browser language of the user?
I found this bit of code below which works to direct users to a different page altogether but I don't see why a similar mechanism couldn't be used to pull individual page elements.
Any ideas on this are much appreciated!
<?php
$lang = strtok($_SERVER['HTTP_ACCEPT_LANGUAGE'],",");
while ($lang)
{
//check if the language is dutch
if (strstr($lang,"nl"))
{
header ("location: ".$modx->makeUrl(2, '', '', 'full'));
exit;
}
//check if the language is english
if (strstr($lang,"en"))
{
header ("location: ".$modx->makeUrl(3, '', '', 'full'));
exit;
}
// etc..
$lang = strtok(",");
}
// no defined language found, go to the english pages
header ("location: ".$modx->makeUrl(3, '', '', 'full'));
exit;
?>