Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/04/2012, 01:50
Avatar de TheScript
TheScript
 
Fecha de Ingreso: septiembre-2011
Ubicación: Spain
Mensajes: 164
Antigüedad: 12 años, 7 meses
Puntos: 30
Respuesta: Múltiples idiomas en la web

Hola Jask, hace tiempo tuve la misma necesidad que tu... como tu dices esta es una de las maneras:

Código PHP:

<?php
// averiguamos cual es el idioma configurado en el navegador del visitante 
if ($HTTP_ACCEPT_LANGUAGE != ''){
    
$idiomas explode(","$HTTP_ACCEPT_LANGUAGE);
    
// Convertimos HTTP_ACCEPT_LANGUAGE en array 
    
for ($i=0$i<count($idiomas); $i++){ 
        if (!isset(
$idioma)){
            if (
substr($idiomas[$i], 02) == "es"){$idioma "es";} 
            if (
substr($idiomas[$i], 02) == "en"){$idioma "en";} 
            if (
substr($idiomas[$i], 02) == "fr"){$idioma "fr";} 
        } 
    } 

// Si no averiguamos el idioma del visitante usamos un idioma por defecto
if (!isset($idioma)){$idioma "es";}  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mi web</title>
</head>
<body>
<?php
switch ($idioma) { 
case 
'es'
  echo 
"Bienvenidos a España"
  break; 
case 
'en'
  echo 
"Welcome to England"
  break;
case 
'fr'
  echo 
"Bienvenue à la France"
  break; 
default: 
  echo 
"Bienvenidos a España"
  break; 
}  
?>
</body>
</html>
También puedes ojear este enlace, en el que dan varias opciones:

http://web.ontuts.com/tutoriales/apl...multilenguaje/


Por otro lado, también vi que hay gente que trabaja con la api de google para traducir textos no muy exagerados.

Espero haberte ayudado aunque sea un poquiyo. Un saludo.