Ignatius881 Posted August 6, 2011 Share Posted August 6, 2011 Hello. Well, I need some help with this problem. I'll explain. I'm helping a friend to develop a webpage, and we decided to internacionalize and localize it. I proposed gettext, I was working on it, and it works. But not as expected. Here are two pieces of code and an image: - /local.php: <?php $locale = "es_ES.utf8"; $I= $_SESSION["IDIOMA"]; if($I=="eo"){ $locale="eo.utf8"; } if($I=="es"){ $locale="es_ES.utf8"; } if($I=="en"){ $locale="en_GB.utf8"; } if (isSet($_GET["locale"])) $locale = $_GET["locale"]; putenv("LC_ALL=$locale"); setlocale(LC_ALL, $locale); bindtextdomain("messages", __DIR__."/locale"); textdomain("messages"); ?> - /es/login.php: <?php require_once(__DIR__."/../local.php"); ?> <?php if($_GET["idiom"]=="es"){include("ES_es.php");} if($_GET["idiom"]=="eo"){include("EO_eo.php");} if($_GET["idiom"]=="vl"){include("ES_vl.php");} if($_GET["idiom"]=="ek"){include("EU_ba.php");} if(isset($SESSION)){ //header("location:user.php?mod=inicio"); /* Si ha iniciado la sesion, vamos a user.php */ //echo '<script>top.location.href="user.php?mod=inicio"</script>'; } else { /* Cerramos la parte de codigo PHP porque vamos a escribir bastante HTML y nos será mas cómodo así que metiendo echo's */ include("function_botones.php"); ?> <title><? print _("Identificación"); ?> </title> <h1><? print _("Inicio de sesión"); ?> </h1> <h2><? print _("Identificación"); ?> <?=$_GET["idiom"]?></h2> <form action="comprueba.php" method="POST" class="miform" name="miform"> <? print _("Nombre:"); ?> <input type="text" name="login"><br> <? print _("Contraseña:"); ?> <input type="password" name="pass"><br> <input type="hidden" name="IDIOMA" value="<?=$_GET["idiom"]?>"/> <br> <!--<input type="submit" value="Entrar" class="boton">--> <table width="100"> <tr> <td><?=Boton(_("Entrar"),"azul","#","miform",false)?></td> </tr> </table> </form> <? } /* Y cerramos el else */ ?> All right, the comments, echos and prints are not important. The output of this code should return a translation of the texts (inicio de sesión > login, contraseña > password, etc.). But this happens: So, /local.php is correct, /index.php (the text behind, originally in Spanish and localized as you can see) is correct, but /es/login.php seems to be wrong or something. I solved the problem about including a file which is in a higher level with __DIR__, but I don't understand. Excuse me, I'm not an expert in php, but I want to learn more. So, what have I to do to see the window text translated? And excuse me if I don't explain well my problem. I hope you can help me. Thanks. Link to comment https://forums.phpfreaks.com/topic/244055-help-with-gettext-and-translations/ Share on other sites More sharing options...
WebStyles Posted August 7, 2011 Share Posted August 7, 2011 you're using: $_GET["idiom"] but in the url the variable is called 'locale' Link to comment https://forums.phpfreaks.com/topic/244055-help-with-gettext-and-translations/#findComment-1253543 Share on other sites More sharing options...
Ignatius881 Posted August 7, 2011 Author Share Posted August 7, 2011 you're using: $_GET["idiom"] but in the url the variable is called 'locale' In fact, that wasn't the correct file Ok, now the login window appears with the translation. But the rest of the page not. And there are many files involved, and I don't know what file is the correct. They are at least four files. Link to comment https://forums.phpfreaks.com/topic/244055-help-with-gettext-and-translations/#findComment-1253687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.