I found an addon that does that, but unfortunately
The site is getting a little slow
Addition name auto_language
This code is from inside the addon
<?php
/*
Plugin Name: Auto Language
Description: Choose an automatic language base on browser language
Version: 1.0
Author: Guillermo Parraguez
Short Name: aLanguage
Plugin update URI: auto-language
*/
function check_language () {
$browser = str_replace("-","_",substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5)); //language in the browser
$list = osc_get_locales(); //list of languages in osclass
$current = osc_current_user_locale(); //current language in osclass
if(!isset($_COOKIE['osc_auto_language']) && !isset($_GET['auto'])){
setcookie("osc_auto_language", true, time()+60*60*24*90, "/");
if($current != $browser){
foreach ($list as $lan_code) {
if($browser == $lan_code['pk_c_code']){
header("Location: index.php?page=language&auto=true&locale=".$browser);
}
}
}
}
}
osc_add_hook('init', check_language());
?>
Is there an error
Because it works some of the time
And other times it doesn't work