Hello,
I try to explain my situation. I need to insert multilanguage support in my php site. I used this script called common.php:
<?php
session_start();
header('Cache-control: private'); // IE 6 FIX
if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie('lang', $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en';
}
switch ($lang) {
case 'en':
$lang_file = 'lang.en.php';
break;
case 'de':
$lang_file = 'lang.de.php';
break;
case 'es':
$lang_file = 'lang.es.php';
break;
default:
$lang_file = 'lang.en.php';
}
include_once 'languages/'.$lang_file;
?>
After I create a folder with translation file: lang.en.php, lang.de.php and lang.es.php in this mode for each language:
<?php
/*
------------------
Language: English
------------------
*/
$lang = array();
$lang['PAGE_TITLE'] = 'My website page title';
$lang['HEADER_TITLE'] = 'My website header title';
....
?>
Now I include common.php (ex. <?php include ('common.php'); ?> ) in first line of my header. Header in included in each php page (ex. <?php include ('header.php'); ?> ).
If I try to insert traslation in this mode:
<title><?php echo $lang['PAGE_TITLE']; ?></title>
I view "?" and I don't view correct translation.
Someone can help me to solve this problem?