Foros del Web » Programando para Internet » PHP »

traducir automaticamente,, babelfish ¿?

Estas en el tema de traducir automaticamente,, babelfish ¿? en el foro de PHP en Foros del Web. Que tal, Quisiera traducir mis textoos automaticamente a varios idiomas, en ese proceso me encontré con la clase babelfish , pero me encuentro con el ...
  #1 (permalink)  
Antiguo 13/12/2008, 16:11
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
traducir automaticamente,, babelfish ¿?

Que tal,

Quisiera traducir mis textoos automaticamente a varios idiomas, en ese proceso me encontré con la clase babelfish , pero me encuentro con el incoveniente que como trabaja directamente con sus servidores, si algun momento ellos cambian su codigo o se les cae el servidor, mis traduccion dejaran de fucionar,,

asi que requiero alguno como babelfish que funcione en mi servidor o como lo puedo adaptar¿?

alguien sabe?

saludos
__________________
*La amistad se multiplica cuando se divide*
  #2 (permalink)  
Antiguo 14/12/2008, 17:58
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Clases de traduccion automaticas de php ¿?

Que tal,

Hal alguna clase de php que traduzca los textos automaticamente ¿??

No me refiero a un traductor de linea, he escuchado de babelfish pero no he encontrado información de donde bajarlo..

Alguien conoce algo parecido ¿?

saludos y gracias ;)
__________________
*La amistad se multiplica cuando se divide*
  #3 (permalink)  
Antiguo 14/12/2008, 18:19
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Clases de traduccion automaticas de php ¿?

Temas unidos por favor no dupliques temas.
  #4 (permalink)  
Antiguo 14/12/2008, 19:35
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: traducir automaticamente,, babelfish ¿?

http://www.phpclasses.org/browse/package/2383.html
  #5 (permalink)  
Antiguo 14/12/2008, 22:02
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Respuesta: traducir automaticamente,, babelfish ¿?

que tal, gracias

he probado la clase , y me sale el siguiente error:

In English: The quick brown fox jumps over the lazy dog.

Fatal error: Call to undefined function curl_init() in D:\xampp\htdocs\Php5 tecnicas\babelfish.class.php on line 117

---------

Mi version actual de php 5 es: 5.2.6

E igualmente tengo activado
extension=php_curl.dll

saludos k podria ser ¿??

gracias ;)
__________________
*La amistad se multiplica cuando se divide*
  #6 (permalink)  
Antiguo 14/12/2008, 22:18
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: traducir automaticamente,, babelfish ¿?

...

revisa si existe la .dll en la carpeta ext/ de tu instalación PHP
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #7 (permalink)  
Antiguo 14/12/2008, 22:23
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Respuesta: traducir automaticamente,, babelfish ¿?

k tal,
me falto el php.ini de xampp\apache\bin

gracias a todos ;)
__________________
*La amistad se multiplica cuando se divide*
  #8 (permalink)  
Antiguo 07/01/2009, 10:19
Avatar de gabyweb  
Fecha de Ingreso: enero-2002
Ubicación: Lima
Mensajes: 364
Antigüedad: 22 años, 3 meses
Puntos: 0
Pregunta Respuesta: traducir automaticamente,, babelfish ¿?

Tuve el mismo problema y lo resolví ok. Pero ahora me muestra el siguiente mensaje:

In French: ** error : babelfish.class.php returned nothing
In Dutch: ** error : babelfish.class.php returned nothing
In Japanese: ** error : babelfish.class.php returned nothing
In Korean: ** error : babelfish.class.php returned nothing
In Chinese: ** error : babelfish.class.php returned nothing
In Russian: ** error : babelfish.class.php returned nothing
In German: ** error : babelfish.class.php returned nothing
In Greek: ** error : babelfish.class.php returned nothing
In Italian: ** error : babelfish.class.php returned nothing

Cuál es el error?

Gracias
__________________
Gaby :adios:
  #9 (permalink)  
Antiguo 07/06/2009, 18:04
 
Fecha de Ingreso: diciembre-2007
Mensajes: 38
Antigüedad: 16 años, 4 meses
Puntos: 0
Hola a todos.....
Reabro este tema porque a mi me sale el mismo error
Cita:
In English: I am a multilingual guy !
In French: ** error : babelfish.class.php returned nothing
In Dutch: ** error : babelfish.class.php returned nothing
¿Alquien lo ha logrado resolver?
Por favor...

Aca esta el codigo de babelfisch.class.php
Código PHP:
<?php
if (!function_exists('')) {
   function 
http_build_query($formdata$numeric_prefix "")
   {
       
$arr = array();
       foreach (
$formdata as $key => $val)
         
$arr[] = urlencode($numeric_prefix.$key)."=".urlencode($val);
       return 
implode($arr"&");
   }
}
/* translate text using altavista babelfish */
class babelfish{
    
/* array to store language names */
    
var $languages      =   NULL;
    
/* stores the altavista babelfish url*/
    
var $babel_url      =   NULL;
    
/* stores the search regex  (see readme for details) */
    
var $search_regex   =   NULL;
    
/* stores the data to be posted in an array (see readme for details) */
    
var $post_data      =   NULL;
    
/* stores the supported translation combination(s) */
    
var $valid_translate   =   NULL;
    
/* class constructor */
    
function babelfish($url=NULL,$postdata=NULL,$regex=NULL){
        
/* Lista de lenguajes */
        
$this->languages    =       array(
                                        
'en'    =>    'english',
                                        
'zh'    =>    'chinese',
                                        
'zt'    =>    'chinese-traditional',
                                        
'nl'    =>    'dutch',
                                        
'fr'    =>    'french',
                                        
'de'    =>    'german',
                                        
'el'    =>    'greek',
                                        
'it'    =>    'italian',
                                        
'ja'    =>    'japanese',
                                        
'ko'    =>    'korean',
                                        
'pt'    =>    'portuguese',
                                        
'ru'    =>    'russian',
                                        
'es'    =>    'spanish'
                                
);
        
/* lista de traducciones validas */
        
$this->valid_translate=array(
            
'zt_en','en_zh','en_zt','en_nl','en_fr',
            
'en_de','en_el','en_it','en_ja','en_ko',
            
'en_pt','en_ru','en_es','nl_en','nl_fr',
            
'fr_en','fr_de','fr_el','fr_it','fr_pt',
            
'fr_nl','fr_es','de_en','de_fr','el_en',
            
'el_fr','it_en','it_fr','ja_en','ko_en',
            
'pt_en','pt_fr','ru_en','es_en','es_fr'
        
);

        
/* babelfish service url */
        
if($url!=NULL)
            
$this->babel_url=$url;
        else
            
$this->babel_url="babelfish.altavista.com/tr";
        
/* data that is posted to the babelfish site */
        
if($postdata!=NULL)
            
$this->post_data=$postdata;
        else
            
$this->post_data=array(
                        
'doit'=>'done',
                        
'intl'=>'1',
                        
'tt'=>'urltext',
                        
'trtext'=>NULL,
                        
'lp'=>NULL
            
);
        
/* search for the translated text using this regex */
        
if($regex!=NULL)
            
$this->search_regex=$regex;
        else
            
#$this->search_regex='/<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/div><\/td>/';
             
$this->search_regex='/<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/div><\/td>/sm';
    }
    
/* perform babelfish translation */
    
function translate($text,$from_language,$to_language){
        
$f=array_search(strtolower($from_language),$this->languages);
        if(!
$f){die("***error: source language not found");}
        
$t=array_search(strtolower($to_language),$this->languages);
        if(!
$t){die("***error: result language not found");}
        
$l=$f.'_'.$t;
        if(!
in_array($l,$this->valid_translate)){die("***error: cant translate with given combination ($l)");}
        
$this->post_data['trtext']=$text;
        
$this->post_data['lp']=$l;
        
$query=http_build_query($this->post_data);
        
$ch=curl_init();
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_URL$this->babel_url);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$query);
        
$output curl_exec($ch);
        
curl_close($ch);
        
$result=preg_match($this->search_regex,$output,$match);
//        return

        
if($result == 1){
             return 
htmlentities(strip_tags($match[0]));
         }else{
             return 
'** error : babelfish.class.php returned nothing';
         }


  
//     strip_tags($match[ 0]);
    
}
}
/* end of class */
?>
y aqui para el ejemplo donde sale el error
Código PHP:
<?php
include("babelfish.class.php");
$message="I am a multilingual guy !";
echo 
"In English: ".$message.'<br>';
$tr=new babelfish();
echo 
"In French: ".$tr->translate($message,'english','French').'<br>';
echo 
"In Dutch: ".$tr->translate($message,'english','dutch').'<br>';
?>

Espero puedan ayudarme
Saludos...

Última edición por GatorV; 07/06/2009 a las 19:57
  #10 (permalink)  
Antiguo 07/06/2009, 19:31
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: traducir automaticamente,, babelfish ¿?

no tienes un error de programación, es obvio que no esta funcionando el script como deseas.... pero eso no quiere decir que este mal!!

entonces, ¿que quieres que hagamos?


o bien, no es un problema como tal... osea, si el script falla en la conexión o es obsoleto no podemos hacer mas....


--
Edito: viendo la forma en que sirve la clase... me doy cuenta que hace un rip, no usa API alguna....

en fin, estudie un poco la clase... y me di cuenta que recibe un parámetro de la expresión regular de extracción...

osea... la expresión que usa la clase si esta obsoleta, en fin, solo hice esto:
Código PHP:
$tr=new babelfish(NULL,NULL,'/<div\s+id="result">\s*<div[^>]*>(.*)<\/div><\/div>/Uis'); 
el resto del código es el mismo, suerte!
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Última edición por pateketrueke; 07/06/2009 a las 20:04 Razón: regex
  #11 (permalink)  
Antiguo 09/06/2009, 09:43
 
Fecha de Ingreso: diciembre-2007
Mensajes: 38
Antigüedad: 16 años, 4 meses
Puntos: 0
Respuesta: traducir automaticamente,, babelfish ¿?

Hermano mio que lindo eres, eres un genio
Muchas gracias....Besos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:23.