Bien, en las páginas incluyo también el archivo saberidioma.php en el cual está el codigo para detectar el idioma y ahí da las rutas hacia los archivos text_es.php y demás idiomas que contienen los array $text[] = "";
Código PHP:
<?php include($_SERVER['DOCUMENT_ROOT']."/conf/idioma/saberidioma.php"); ?>
y el código de saberidioma.php es el siguiente:
Código PHP:
<?php
$idioma = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : "";
if ($idioma == "") {
$idioma = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$idioma = substr($idioma, 0, 2);
}
if ($idioma == "es") {
require_once($_SERVER['DOCUMENT_ROOT']."/conf/idioma/text_es".$string.".php");
}
elseif ($idioma == "en") {
require_once($_SERVER['DOCUMENT_ROOT']."/conf/idioma/text_en".$string.".php");
}
if(isset($_GET['lang'])) {
$idioma = $_GET['lang'];
setcookie("lang", $idioma, time() + (3600 * 24 * 30), '/');
}
else if(isSet($_COOKIE['lang'])) {
$idioma = $_COOKIE['lang'];
}
else {
$idioma = 'es';
}
switch ($idioma) {
case 'en':
$lang_file = 'text_en.php';
break;
case 'es':
$lang_file = 'text_es.php';
break;
default:
$lang_file = 'text_es.php';
}
include_once($_SERVER['DOCUMENT_ROOT']."/conf/idioma/".$lang_file);
?>