Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/12/2008, 02:44
iovan
 
Fecha de Ingreso: septiembre-2007
Ubicación: PyRoot
Mensajes: 1.515
Antigüedad: 16 años, 7 meses
Puntos: 188
¿Como incorporar multi-lenguaje en mi sitio web?

Buenas a todos.

He leido alrrededor de 5 mensajes en este foro que hablan sobre mi tema, tambien 3 faqs y mucha informacion de internet, pero no he conceguido una el multilenguaje compatible con la estructura de mi sitio web

Recientemente fabrique un pequeño sistema en PHP sin usar bases de datos, ahora deseo incorporar multilenguaje a mi sitio pero no puedo hacerlo de la manera que yo planeaba.

Explico, mi sitio web actualmente tiene esta sintaxis

Misitio
Código HTML:
/includes/   
         /config.php
        /language/spanish.php
       /language/english.php
index.php
contact-us.php
Lo anteriro es un ejemplo de la estructura usada en la creacion de mi sitio, includes y language son directorios.

mis archivos estan mas o menos asi:

includes/config.php
Código PHP:
<?php
$style 
"themes/default/style.css";

$lang "spanish";

?>
includes/language/spanish.php
[PHP]
<?php

$lang['title'] = 'Mi titulo';
$lang['text1'] = 'Cualquier texto en español';
$lang['text2'] = 'Cualquier otro texto en español';

$lang['name'] = 'Introdusca su nombre:';
$lang['lastname'] = 'Introdusca su apellido:';
$lang['email'] = 'Introdusca su email:';

?>
[/PHP

includes/language/english.php
Código PHP:
<?php

$lang
['title'] = 'My title';
$lang['text1'] = 'Any text in English';
$lang['text2'] = 'Any other text in English';

$lang['name'] = 'Enter your name:';
$lang['lastname'] = 'Enter your lastname:';
$lang['email'] = 'Enter your email:';

?>

index.php
Código PHP:
<?php include('includes/config.php');?>
<?php 
include('includes/language/'.$lang.'.php');?>
<html>
<head>
<title> <?php echo $lang['title'];?> </title>
<style link="rel" type="text/css" href='<?php echo "$style";?>'>
</head>
<body>
<?php echo $lang['text1'];?>
</body>
</html>
contact-us.php
Código PHP:
<?php include('includes/config.php');?>
<?php 
include('includes/language/'.$lang.'.php');?>
<html>
<head>
<title> <?php echo $lang['title'];?> </title>
<style link="rel" type="text/css" href='<?php echo "$style";?>'>
</head>
<body>
<?php echo $lang['text2'];?>
<form>
<?php echo $lang['name'];?><input type="text">
<?php echo $lang['lastname'];?><input type="text">
<?php echo $lang['email'];?><input type="text">
</form>
</body>
</html>
En este script se puede cambiar el lenguaje al ingles si se cambia el valor de "$lang" en config.php

Pero lo que necesito es:

*Cambiar el idioma de la página al dar click en por ejemplo:
view in english | ver en español

*Conservar el idioma seleccionado al navegar entre links.
He visto que las paginas utilizan por ejemplo:

index.php?lang=en
contact-us.php?lang=en

*Establecer un idioma por defecto si el usuario no selecciona ninguno.

Muchas gracias por la ayuda.
Saludos!