Help with some pieces of code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ignatius881
Forum Newbie
Posts: 17
Joined: Thu Jul 14, 2011 9:09 am
Location: Oviedo (Spain)

Help with some pieces of code

Post by Ignatius881 »

Hello.

Well, I already know how to use gettext and how to include files which are not in the same folder. But I need more help.

Look at these pictures:

- https://lh4.googleusercontent.com/-Iudp ... 440/18.png

- https://lh6.googleusercontent.com/-N8iP ... 440/19.png

I haven't to explain the problem, you'll see it perfectly. The index.php file (Welcome to ...) is adapted to gettext and it works. The login.php file is adapted to gettext, but it doesn't work, and I don't know why.

Here are the code of the files involved:

- /local.php:

Code: Select all

<?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

Code: Select all

<? require_once(__DIR__."/../local.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 */ 
?>
The text (comments, echos, prints...) is not important, the important thing is to know why the login window doesn't show the translation.

Thanks for your help.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Help with some pieces of code

Post by Jonah Bron »

Is the login form being shown as an iframe, or is it hidden when the page loads and shown when you click the "Log in" button?
Post Reply