Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including a second language file

Status
Not open for further replies.

plarsen

Programmer
Jul 30, 2002
27
DK
Hi

I have a script with 2 language files (german and danish).

First i include the german language file because the user is german, then the user sends a message to a danish user and that triggers an e-mail to the danish user, but the danish user gets a german e-mail instead of a danish.

I have tried to include the danish language file but since the german language file was included first, it is this file that is used.

How can i get the script to use the second language file i included (danish)?

Can i in any way exclude again?

I hope you can help me.
 
I'm not sure what you're asking. Are you mailing files or?

Post some code (the shorter and more precise, the better).

Regards


Jakob
 
Hi Jakob

Here are the code to send a notification of a new message in the system.

Code:
    require_once("lang/de.inc.php"); //The user logged in are from Germany, therefor the de.inc.php language file

    .....

    function message_sent($recipient, $sender) {
      if (is_a($recipient,'User') && (is_a($sender,'User'))) {
        if (is_file("lang/" . strtolower($recipient->country->lang_file))) { //Does the language fíle for the recipient language exists
          require_once("lang/" . strtolower($recipient->country->lang_file)); //Include the language file for the recipients language
        }
        $this->IsHTML(true);
        $this->Subject = MESSAGE_ARRIVED;

        $this->Body  = "<font face=\"Verdana\">".GREETING." ".$recipient->username.",\n\n<br><br>";
        $this->Body .= MESSAGE_ARRIVED1;
        if (is_a($sender,'Buddy')) $this->Body .= $sender->username . ", " . $sender->city;
        else $this->Body .= $sender->get_pid();
        $this->Body .= MESSAGE_ARRIVED2."\n<br>";
        $this->Body .= MESSAGE_ARRIVED3;
        $this->Body .= MESSAGE_ARRIVED4."</font>";

        $this->AddAddress($recipient->email,$recipient->username);

        $this->Send();
        if (is_file("../lang/" . strtolower($sender->country->lang_file))) { //Does the language fíle for the senders language exists
          require_once("../lang/" . strtolower($sender->country->lang_file)); //Include the language file for the senders language

        }
      }
    }

This function is triggered then a user are sending a new message to another user.

In the above code the reference to a value in the language file is eg. MESSAGE_ARRIVED, and what value should be taken from the recipients language file.

I hope that this is enough to descripe my problem.

Thanks

Peter
 
because you are using definitions including a new language file, which assumedly contains lots of definition - eg:
Code:
define("MESSAGE_ARRIVED", "text");

will not override the definitions in the first included file. definitions are global in scope and cannot be reset in the script.

solutions:
1. split the email language files out into a separate file
2. change from using definitions to variables (at least for the emails)
3. change the interaction so that this script just leaves a text file with info on the server and then set up a cron job to run every couple of minutes to parse the text files and create the emails.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top