Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/03/2011, 17:49
Avatar de humbero12
humbero12
 
Fecha de Ingreso: abril-2009
Ubicación: Cereté, Colombia
Mensajes: 53
Antigüedad: 15 años
Puntos: 4
Respuesta: Como filtrar usuarios por idioma??

Se puede hacer guardando los idiomas en la base de datos y generando las funciones con un eval dependiendo del registro que tenga en la base de datos pero te muestro como se hace con archivos mira el siguiente codigo:

Código PHP:
Ver original
  1. <?php
  2. function getIdioma(){
  3. $leng = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  4. $exp = explode(";",$leng);
  5. $leng = $exp[0];
  6. switch($leng){
  7.     case strpos($leng,"es"):
  8.     $leng = "es";
  9.     break;
  10.     case strpos($leng,"en"):
  11.     $leng = "en";
  12.     break;
  13.     case strpos($leng,"fr"):
  14.     $leng = "fr";
  15.     break;
  16.     default: //Si no es ninguno de los anterior el idioma por defecto es ingles
  17.     $leng = "en";
  18. }
  19.    
  20.     return $leng;
  21. }
  22.  
  23. function encabezado(){
  24.     $texto_es = "Encabezado en español";
  25.     $texto_en = "Header English";
  26.     $texto_fr = "Français-tête";   
  27.     return  ${'texto_'.getIdioma()};
  28. }
  29.  
  30. function cuerpo(){
  31.     $texto_es = "Texto del documento todo en español, aquí todo la información";
  32.     $texto_en = "Text of the document all in English, here all the information";
  33.     $texto_fr = "Le texte du document tout en français, ici toutes les informations";  
  34.     return  ${'texto_'.getIdioma()};
  35. }
  36. ?>
  37. <html>
  38. <head>
  39. <meta content="text/html; charset=UTF-8" http-equiv="content-type">
  40. <title></title>
  41. </head>
  42. <body>
  43.     <h1><? echo encabezado(); ?></h1>
  44.     <? echo cuerpo();?>
  45. </body>
  46. </html>

Espero que te sirva

__________________
Sigueme en twitter @humbero12
Blog #cazacontenidos