Language redirect

General questions about CMSimple
Post Reply
markus.leder
Posts: 9
Joined: Sun Sep 14, 2008 3:47 am

Language redirect

Post by markus.leder » Fri Dec 12, 2008 3:01 am

Making a CMsimple multilanguage site is great!!!
But I desperately need a "automated" redirect to "browserlanguage" or "country" so english visitors don't go first to the "default dutch page" and click away before finding a "small flag in the corner"...
Anyone knows how to get this done?

Please, any help is verrrrrry welcome!

Connie
Posts: 282
Joined: Thu May 22, 2008 10:11 am
Location: Hamburg
Contact:

Re: Language redirect

Post by Connie » Fri Dec 12, 2008 7:21 am

there is not such a plugin

but you can try to do something with a .htaccess which redirects to the relevant language

good luck,

Connie
|---
Connie Müller-Gödecke, http://www.webdeerns.de

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Language redirect

Post by Holger » Fri Dec 12, 2008 8:19 am

Should be easy done by JavaScript, too.

It's a nice idea.
I'm thinking about writing a little plugin on that...

Holger ;)

... but remember maybe the language, returned from the Browser, must not be the language the user prefers to read.
So redirection should only done with the first visit.

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Language redirect

Post by bastingse » Mon Jan 05, 2009 8:09 pm

make a new index.php (and rename the old to index2.php) a let visitors choose there language on index.php???

harteg
Posts: 27
Joined: Wed May 28, 2008 11:55 am

Re: Language redirect

Post by harteg » Thu Jan 22, 2009 8:27 pm

To be placed in top of template:

Code: Select all

$uc = substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if($uc==""||$uc=="dk")$uc="da";
if($uc=='da'&&$sl!='da'){header("Location: http://www.domain.dk/da/");exit;}
if($uc=='de'&&$sl!='de'){header("Location: http://www.domain.dk/de/");exit;}

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Language redirect

Post by Holger » Thu Jan 22, 2009 10:56 pm

harteg wrote:To be placed in top of template:

Code: Select all

$uc = substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if($uc==""||$uc=="dk")$uc="da";
if($uc=='da'&&$sl!='da'){header("Location: http://www.domain.dk/da/");exit;}
if($uc=='de'&&$sl!='de'){header("Location: http://www.domain.dk/de/");exit;}
That's IMHO a bad idea. :?
An empty $uc should do nothing. So the visitor will see the pages with the default language.

And what about looking on a page in german language when your browser language is set to "dk"?
There's no chance to see the page http://www.domain.dk/da/?Very_interesting_page with a german browser.

Automatic redirection should only done on the first page request and only if the main domain was requested.

Holger

Post Reply