Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks Gregory (@tivnet), I really appreciated your corrections, I’m not an experienced PHP developer, I will surely do the suggested minor change.

    I agree that it’s not the right way to translate pages. Forcing the user to get a language is a despotic behaviour. =)
    Unfortunately the customer isn’t always right and he wants silly things.

    Hi, is there any news about this scheduled functionality?
    By the way, I wrote a few lines of code to temporarily provide a solution.

    It checks only the browser’s language settings, not the navigator or the GEO ip. In every case it works. I put it at the beginning of the header.php of my theme…

    <?php
    	$langs=explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
    	if(!is_array($langs))$langs=array($langs);
    	foreach($langs as $l){
    		$reallang=(strlen($l)>2)?strtolower(substr($l,0,2)):strtolower($l);
    		if(!class_exists('WPGlobus'))break;
    		$currentlanguage=WPGlobus::Config()->language;
    		/*echo "Testing browser lang $reallang<br>Current language is $currentlanguage<br>";*/ //DEBUG
    		if($reallang==$currentlanguage)break;
    		foreach(WPGlobus::Config()->enabled_languages as $lang) {
    			if($lang==$reallang)header("Location: ".WPGlobus_Utils::localize_current_url($lang));
    		}
    	}
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)