View Full Version : bilingual site navigation problem

10-30-2007, 02:47 PM

I am maintaining an English website and now want to add a German version.
I plan to add an extra folder, where the German pages are located, and the user can choose his language at an entry page.

The problem now is, that there is a guestbook, which should be accessible from both versions. But all the links in the guestbook are pointing to the English version although German visitors should be directed back to the German version.

I know that it is possible to achieve this serversided, but actually have no clue, how I can code this. :confused:

Thanks for your help in advance!

10-30-2007, 04:49 PM
personally I would set up so the site uses the same pages for all the site. Then use different sub domains to determine which language to echo back through the pages.

function get_subdomain() {
// Explode the HOST into it's constituent parts:
$parts = explode('.', $_SERVER['HTTP_HOST']);
$cp = count($parts);

// If a 1 part hostname like 'localhost' don't bother with a subdomain:
if ($cp == 1) { $subdomain = ''; }
// Otherwise, generate our subdomain by using the last 2 parts
else { $subdomain = ".{$parts[$cp-2]}.{$parts[$cp-1]}"; }

return $subdomain;

if ($subdomain=='uk')
echo 'Welcome to Uk site';
}elseif ($subdomain=='de')
echo 'Welcome to German site';