<?php
if (isset($_GET['lang'])) {
setcookie("lang", $_GET['lang'], time()+365*24*60*60, "/");
Header('Location:?');
}
$tr['Site menu'] = [
'ru' => 'Меню сайта',
'es' => 'Menu del sitio',
];
function _($def) {
global $tr;
$ret = $def;
if (isset($tr[$def])) {
$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : '';
if (isset($tr[$def][$lang])) {
$ret = $tr[$def][$lang];
} // else throw new Exception('Translation to language "'.$lang.'" for phrase "'.$def.'" not found');
} // else throw new Exception('Default translation for phrase "'.$def.'" not found');
return $ret;
}
?>
<!doctype html5>
<html>
<head><meta charset="utf-8" /> </head>
<body>
<a href="?lang=en">En</a>
· <a href="?lang=ru">Ru</a>
· <a href="?lang=es">Es</a>
· <a href="?lang=ar">Ar</a>
<hr>
<?=_('Site menu')?>
</body>
</html>
?>
<!doctype html5>
<html>
<head><meta charset="utf-8" /> </head>
<body>
<a href="?lang=en">En</a>
· <a href="?lang=ru">Ru</a>
· <a href="?lang=es">Es</a>
· <a href="?lang=ar">Ar</a>
<hr>
<?=_('Site menu')?>
</body>
</html>