I can continue my work?
Now I’m working on lang_core.php.
However my system works like this:
there are one new folder called “lang”, in this folder there are, lang_core.php and one o more $lang.php (e.g. en-en.php, it-it.php…)
lang_core.php
This determines the nationality of the user using $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] method and creating a cookie in the user PC containing language id, (e.g. en-us, it-it, en-en).
So, in every page lang_core.php reads the cookie content and insert the value in a variable $lang and select the respective $lang.php file which contains the variables with string translated.
Is it possible my idea?
$lang.php
<?php
//it-it
//Italian language
//translated by Marco Carbone
$Unauthorized_access = ‘Accesso non autorizzato!’;
$Graph_Title_Pireps_filed = ‘Pireps Compilati’;
$Install_folder_exist_security_risk = ‘La cartella d’installazione esiste ancora! Questo crea un rischio di sicurezza elevato. Eliminalo subito!’;
$Unable_to_connect_to_phpvms_server_to_update = ‘<br /><b>Errore:</b> Il server di aggiornamento phpVMS non può essere contattato. Assicurati che allow_url_fopen sia ON nel php.ini, o che il module cURL sia installato (contatta il tuo host).’;
$phpVMS_Version = ‘/^.*Versione: (.*)</span>/’;
$phpVMS_Version_Available = 'Versione ';
$phpVMS_Version_is_Available = ’ è disponibile per il download! Aggiorna ASAP’;
$Add_Download_Category = ‘Aggiungi categoria’;
$Add_Download = ‘Aggiungi Download’;
$Va_Stats = ‘Statistiche Virtual Airline’;
$Total_Pilots = 'Totale Piloti: ';
$Total_Flights = 'Totale Voli: ';
$Total_Hours_Flown = 'Totale ore di volo eseguite: ';
$Latest_News = ‘Ultime notizie’;
$Administration_Panel = ‘Pannello di amministrazione’;
$Pilot_Reports_for_Week = ‘Rapporti dei piloti della settimana scorsa’;
Work in progress
?>
So, to work this system have to include this:
include (“../lang/lang_core.php”);
include (“../lang/$lang.php”);
in every page, and the content must be variable, for example:
…
Create the chart
//$reportcounts = ‘’;
$reportcounts = PIREPData::ShowReportCounts();
if(!$reportcounts)
{
$reportcounts = array();
}
include (“../lang/lang_core.php”);
include (“../lang/$lang.php”);
$graph = new ChartGraph(‘pchart’, ‘line’, 680, 180);
$graph->setFontSize( 8 ) ;
$graph->AddData($reportcounts, array_keys($reportcounts));
$graph->setTitles($Graph_Title_Pireps_filed);
$graph->GenerateGraph();
…
Marco
Update: I have just finish to write lang_core.php, this is the code:
<?php
$lang_id = mb_substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’],0, -30, ‘UTF-8’);
$Host = $_SERVER[‘HTTP_HOST’];
setcookie($Host, $lang_id, time()+86400);
$lang_name = $_COOKIE[Host];
?>
but there are some errors…
1)Warning: Cannot modify header information - headers already sent by (output started at C:xampphtdocsphpvmscoreclassesTemplateSet.class.php:221) in C:xampphtdocsphpvmslanglang_core.php on line 6
2)Warning: include(../lang/.php) [function.include]: failed to open stream: No such file or directory in C:xampphtdocsphpvmsadminmodulesDashboardDashboard.php on line 99
Warning: include() [function.include]: Failed opening ‘../lang/.php’ for inclusion (include_path=‘.;C:xamppphppear’) in C:xampphtdocsphpvmsadminmodulesDashboardDashboard.php on line 99
3)Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:xampphtdocsphpvmsadminindex.php:53) in C:xampphtdocsphpvmscorecodon.config.php on line 40
4)Warning: include() [function.include]: Failed opening ‘../lang/.php’ for inclusion (include_path=‘.;C:xamppphppear’) in C:xampphtdocsphpvmsadmintemplatesdashboard.tpl on line 5
but the second, third and fourth errors after a page reload, disappears, but only using Mozilla Firefox… :-[