[TYPO3-english] Language Detection, rlmp_language_detection
Urs Bräm
info at ursbraem.ch
Mon May 23 19:19:46 CEST 2011
Hi
I do Language Detection on the home page only (as in the subpages,
language param is usually already in the URL) with a userFunc in PHP (I
call it on the home page and kick it out on all the other pages).
Below's the code I use. I think you might have more chances to get it
precisely to do what you need (location detection) than a large extension.
PS: No guarantee that everything is perfect here :-)
Regards
Urs
<?php
class user_langDetect {
var $cObj;// The backReference to the mother cObj object set at call time
function main(){
// get server vars
$domain = t3lib_div::getIndpEnv('HTTP_HOST');
$uri = t3lib_div::getIndpEnv('REQUEST_URI');
$clientLanguages = t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE');
$cl = substr($clientLanguages,0,2);
// do something
if (($uri == '/')||($uri == '')){
if((stristr($uri,'/fr/'))||($cl == 'fr')){
header("Location: http://example.com/fr/", true, 301);
}
elseif((stristr($uri,'/it/'))||($cl == 'it')){
header("Location: http://example.com/fr/", true, 301);
}
// fallback de
else{
header("Location: http://example.com/de/", true, 301);
}
}
$content.='';
return $content;
}
}
?>
Am 23.05.11 16:45, schrieb Jacob Schmidt:
> Hi,
>
> Does any one knows if it is possible to configure the
> extension,rlmp_language_detection, so it redirects to English(en) if
> language of the browser is not Danish(dk), or the IP is not in Denmark?
>
> My defalut site language, L=0, is Danish and second, L=1, is English.
>
> As I read the manual, I would have to configure a lot of
> "languageAliases" to achieve this?
>
>
> Best regards
> Jacob
--
Urs Bräm
macht Websites
---
Certified Typo3 Integrator
CH-3011 Bern
www.ursbraem.ch
More information about the TYPO3-english
mailing list