HI all, i hope that you wil lassist me with this problem.
The general idea is to have all language variables in one file per language and to display them where it is needed.
Now, i have the following:
In page index.php
PHP Code:
// database connection, setting the $lang etc...
include ("inc/dictionary_$lang.php");
include_once ("inc/function.php");
// fetch info from db
$strana = "SELECT id AS page_id, strana_$lang AS naslov, template_id FROM strane WHERE id='$page_id'";
$result = mysql_query($strana);
$myrow = mysql_fetch_array($result);
$page_id=$myrow["page_id"];
$naslov=$myrow["naslov"];
$template=$myrow["template_id"];
// Insert head and top of the page
include ("inc/top.html");
// Insert main part of page
include ("templates/template$template.htm");
// something
in dictionary_$lang.php
i have the following
PHP Code:
$f_name = "Name";
$f_lastname = "Last name";
// and so on...
html template looks like this:
HTML Code:
...
<tr>
<td width="210"><? echo $f_lastname?> * </td>
<td width="290"><input name="lastname" type="text" id="lastname" /></td>
</tr>
<tr>
<td><? echo $f_name?>* </td>
<td><input name="name" type="text" id="name" /></td>
</tr>
...
this is from function.php
PHP Code:
function print_fields ()
{
switch ($form)
{
case 1:
// array to describe fields
$mail_1 = array($f_lastname, $f_name, 'adress', 'plz');
// array to print values
$mail_2 = array($_POST['lastname'], $_POST['name'], $_POST['adress'], $_POST['plz'];
break;
if ($mail_2)
{
// print description and values
echo '<table border=1 width=500>';
for($i=0; $i<=count($mail_1)-1; $i++)
{
echo '<tr>';
echo ' <td width=150>'.$mail_1[$i].': </td>';
echo ' <td>'.$mail_2[$i].'</td>';
echo '<tr>';
}
echo '</table>';
}
else
{
echo " error";
}
}
This doesn't work, since function doesn't recognize variables from dictionary file.
If i change fucntion to this
PHP Code:
function print_fields ()
{
GLOBAL $lang;
include ("inc/dictionary_$lang.php");
// etc
it works, but i don't see it as nice solution... any suggestions?