class Language {
protected $CI;
public $deft_lang;
public $json;
public $patch;
public function __construct()
{
$this->CI =& get_instance();
$this->CI->load->helper('lang');
$this->CI->load->helper('cookie');
$lan = substr($this->CI->config->item('language'), 0, 2);
$this->deft_lang = (get_cookie('lang') != $lan) ? get_cookie('lang') : $lan;
set_cookie('lang', $this->deft_lang,93062220);
$this->patch = APPPATH.'/lang/'.$this->deft_lang.'.json';
if(file_exists($this->patch))
{
$json = file_get_contents($this->patch);
$this->json = json_decode($json, true);
}
}
public function search($message,$par = NULL)
{
if(!empty($this->json))
{
if (array_key_exists($message, $this->json))
$mes = $this->json[$message];
else $mes = $message;
}
else $mes = $message;
return str_replace("%%s%%", $par, $mes);
}
}