My page structure looks like:
- Home
- NL
- NLpage1
- NLpage2
- EN
- Enpage1
- Enpage2
- FR
- FRpage1
- FRpage2
I created a UDT called "browserlanguage" that holds:
Code: Select all
{
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
if (substr($lang, 0, 2) == 'en')
{
header("Location: index.php?page=en");
} elseif (substr($lang, 0, 2) == 'fr')
{
header("Location: index.php?page=fr");
} else {
header("Location: index.php?page=nl");
}
}
Content-page 'Home' has this tag in the contentpage.
Insert in the template, where you want the flags to appear for the language. page="XX", where "XX" is the language page in the menu. This is to have the ability to choose a language different than their browser or the default.
Code: Select all
<div style="float: right;">
{cms_selflink page="en" image="uploads/flags/lang_en.gif" alt="English" imageonly=1}
{cms_selflink page="fr" image="uploads/flags/lang_fr.gif" alt="French" imageonly=1}
{cms_selflink page="nl" image="uploads/flags/lang_nl.gif" alt="Nederlands" imageonly=1}
</div>
Code: Select all
{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
You can test this on http://demo.krijt.eu, where the code described above is active. For users on IE, the language pulled is the language on top in "Tools -> Internet Options -> Languages".
As you all can see the default language is "NL", so for most users that have their language set to "EN", the script should bring them to the English page.
Ronny