Utilizando Gettext para poder tener una web con varios idiomas me estoy volviendo loco al intentar guardar el idioma seleccionado al cambiar de página. He probado con sessions y cookies pero, la verdad, no lo he logrado. He leído y releído foros y la web de php. Pero no consigo adaptarlo. Agradecería muchísimo que me indicarais cómo hacerlo, a ser posible, con cookies.
Os adjunto el código que he hecho para trastear con gettext:
1a página
Código PHP:
<?php
$language=(isset($_REQUEST['language']))?trim(strip_tags($_REQUEST['language'])):"es_ES";
putenv("LC_ALL=$language");
setlocale(LC_ALL, $language);
bindtextdomain("messages", "./locale");
textdomain("messages");
bind_textdomain_codeset("messages", 'UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento sin título</title>
</head>
<body>
<?php print "<p><a href=\"".$_SERVER['PHP_SELF']."?language=en_GB\">English</a> - <a href=\"".$_SERVER['PHP_SELF']."?language=es_ES\">Español</a></p>\n";?>
<br /><br />
<?php print _("What do we say to the god of death?"); ?>
<br />
<a href="bbb.php">Next page</a>
</body>
</html>
Código PHP:
<?php
$language=(isset($_REQUEST['language']))?trim(strip_tags($_REQUEST['language'])):"es_ES";
putenv("LC_ALL=$language");
setlocale(LC_ALL, $language);
bindtextdomain("messages", "./locale");
textdomain("messages");
bind_textdomain_codeset("messages", 'UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento sin título</title>
</head>
<body>
<?php print "<p><a href=\"".$_SERVER['PHP_SELF']."?language=en_GB\">English</a> - <a href=\"".$_SERVER['PHP_SELF']."?language=es_ES\">Español</a></p>\n";?>
<br /><br />
<?php print _("Not today!"); ?>
<br />
<a href="aaa.php">Next page</a>
</body>
</html>
Muchas gracias!!!