conec_leng = mysql_connect($confdb->serverdb,$confdb->userdb,$confdb->passdb); mysql_select_db($confdb->namedb,$this->conec_leng) or die(mysql_error()); $this->conectado=true; unset($confdb); } private function desconectar(){ if($this->conectado) mysql_close($this->conec_leng); } // //Traductir: Traduce un String de máximo 250 caracteres // public function Traductir($string){ $valida_idioma = FALSE; $cierra=false; $Lval_retorna = $string; if(isset($_SESSION["idioma"])) { //if ($_SESSION["idioma"]=="en") $valida_idioma = TRUE; $valida_idioma = TRUE; } if($valida_idioma){ $string_ = ($string); $str="select espanish,english from lenguaje where key_word = '$string'"; if(!$this->conectado){ $this->conectar(); } //$resinde = mysql_query($str) or die(parent::Errores(mysql_error(),mysql_errno())); $resinde = mysql_query($str,$this->conec_leng) or die(mysql_error()); if(mysql_num_rows($resinde)>0){ $rec=mysql_fetch_array($resinde); mysql_free_result($resinde); if ($_SESSION["idioma"]=="en"){ $Lval_retorna = $rec["english"]; $this->lenguaje ="en"; }else{ //ÁÉÍÓÚÑ $Lval_retorna = $rec["espanish"];//htmlentities(utf8_decode(html_entity_decode($rec["espanish"]))); $this->lenguaje ="es"; } unset($rec); }else{ if(trim($string)!==""){ $string_keyword = $string; //$string = htmlentities(utf8_encode($string)); mysql_query("insert into lenguaje (espanish,english,key_word) values('$string','','$string_keyword');",$this->conec_leng) or die(mysql_error()); } } } if(trim($Lval_retorna)=="") $Lval_retorna = $string; return $Lval_retorna; } //* //Traductir_C: TRADUCDEO LOS CAMPOS MEMOS //$string: es el nombre de la palabra clave para traducir un campo tipo memo // public function Traductir_C($codigo,$string,$solomuestra=false){ $valida_idioma = FALSE; $Lval_retorna = $string; if(isset($_SESSION["idioma"])) { //if ($_SESSION["idioma"]=="en" || $_SESSION["idioma"]=="pt") $valida_idioma = TRUE; if ( $this->get_lenguaje()=="en" || $solomuestra==true) $valida_idioma = TRUE; } if($Lval_retorna=="" && !$valida_idioma){ $valida_idioma = true; } if($valida_idioma){ if(!$this->conectado) $this->conectar(); $str="select espanish,english,portugues from lenguajec where codigo = '$codigo'"; $resinde = mysql_query($str,$this->conec_leng) or die(mysql_error()); if(mysql_num_rows($resinde)>0){ $rec=mysql_fetch_array($resinde); mysql_free_result($resinde); if ($this->get_lenguaje()=="en"){ $Lval_retorna = ($rec["english"]); }elseif($this->get_lenguaje()=="es"){ $Lval_retorna = ($rec["espanish"]); } unset($rec); }else{ if(trim($string)!=="" && $solomuestra==false){ mysql_query("insert into lenguajec (codigo,espanish,english,portugues) values('$codigo','$string','','');",$this->conec_leng) or die(parent::Errores(mysql_error(),mysql_errno())); } } } if(trim($Lval_retorna)=="") $Lval_retorna = $string; return $Lval_retorna; } function set_lenguaje($idioma=""){ if($idioma=="") { if(!isset($_SESSION["idioma"])){ $var = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); $leng_explor = explode("-",$var[0]); unset($var); //if($leng_explor[0]=="es" || $leng_explor[0]=="en" || $leng_explor[0]=="pt") if($leng_explor[0]=="es" || $leng_explor[0]=="en") $_SESSION["idioma"] = $leng_explor[0]; else $_SESSION["idioma"] = "en"; unset($leng_explor); } }else{ if($idioma=="es" || $idioma=="en"){ $_SESSION["idioma"] =$idioma ; }else{ $_SESSION["idioma"] ="en" ; } } } function get_lenguaje(){ if(isset($_SESSION["idioma"])){ return $_SESSION["idioma"]; }else{ return "en"; } } function showlenaguaje(){ $file = basename($_SERVER['SCRIPT_NAME']); if($this->get_lenguaje()=="en"){ echo '
Idioma
'; }else{ echo '
Languaje
'; } } } $lenguaje= new Lenguaje(); ?>