Page 1 of 1

Locale Switcher

Posted: Sat 26. Mar 2005, 15:08
by Paal
Oliver Georgi wrote:If you use multiple languages in phpwcms like this:

HOME
- de
- en
- fr

and you want to use language based redirection fill in these lines of code in header section of default template

Code: Select all

[PHP]
if(!$GLOBALS['aktion'][0]) {

	switch( strtolower( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) ) ) {
		case 'de':	header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?de');
					exit();
					break;
		default:	header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?en');
					exit();		
	}

}
[/PHP]
Enhance the other languages like "case 'de':"

Oliver
Hello,

I use this function in 1.1.4.

Does it work in 1.2.1-DEV?
I try it in template/header block, but there is no result :( :

Code: Select all

[PHP]

if(!$GLOBALS['aktion'][0]) {

   switch( strtolower( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) ) ) {
      case 'hu':   header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?lang,hu');
               exit();
               break;
      default:   header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?lang,en');
               exit();      
   }

}
[/PHP]

Posted: Sat 26. Mar 2005, 17:21
by Pappnase
hello

i work with this at the docu site and it works well!
in the header block is some codechanges needed. i will post it tonight!