<?php
function translate($rus,$eng)
{
$lang = $_GET['lang'];
$cookie_fresh = mktime(23,59,59,12,31,date('Y')+1);
if ($lang == 'eng')
{
setcookie('lang', 'eng', $cookie_fresh);
header("Location: ./");
}
if (($lang == 'rus') or (!isset($_COOKIE['lang'])))
{
setcookie('lang', 'rus', $cookie_fresh);
header("Location: ./");
}
if ($_COOKIE['lang'] == 'eng')
{
echo $eng;
}
if ($_COOKIE['lang'] == 'rus')
{
echo $rus;
}
return true;
}
?>
<?php translate('Русские буквы', 'English words'); ?>
function translate($rus, $eng)
{
static $lang;
if (isset($_GET['lang']))
{
$lang = $_GET['lang'] == 'eng' ? 'eng' : 'rus';
setcookie('lang', $lang, time() + 3600 * 24 * 365, '/');
unset($_GET['lang']);
}
elseif (empty($lang))
$lang = $_COOKIE['lang'] == 'eng' ? 'eng' : 'rus';
echo $$lang;
}
<?php
function translate($rus,$eng)
{
$lang = $_GET['lang'];
$cookie_fresh = mktime(23,59,59,12,31,date('Y')+1);
$c_lang = isset( $_COOKIE['lang'] ) ? $_COOKIE['lang'] : 'ru';
if ( $lang == 'eng' && $c_lang != $lang )
{
setcookie('lang', 'eng', $cookie_fresh);
header("Location: ./");
exit();
}
if ($c_lang != $lang && ($lang == 'rus' or !isset($_COOKIE['lang'])))
{
setcookie('lang', 'rus', $cookie_fresh);
header("Location: ./");
exit();
}
switch( $_COOKIE['lang'] ){
case 'eng':
echo $eng;
break;
case 'ru':
echo $rus;
break;
}
return true;
}
?>