0

Who can help me with the following.
I have an allertbox with text in it but i want different languages for the text in the allertbox

$lang = array();

$lang['ALERTBOX_A'] = 'To do this, you must first be logged in.';

onClick="alert(' <?php $lang['ALERTBOX_A']; ?>')"

In this case the language is in english but i have tree different langauges. That deppends on the choise of the user.

with this code i don't see anny text in the allertbox.
How can i fix it ?

Thanks

3
Contributors
5
Replies
17
Views
4 Years
Discussion Span
Last Post by radhakrishna.p
0

We would need to see your whole code, so we can better help you debug the script. If you do this, we can then look at other possible variables that may be affecting the outcome of your code.

0

sorry could not responce earlier.
oke here is the full code

<?php
header('Cache-control: private'); // IE 6 FIX
header('Content-Type: text/html; charset=UTF-8');
if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];

// register the session and set the cookie
$_SESSION['lang'] = $lang;

setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'nl';
}

switch ($lang) {    

    case 'nl':
  $lang_file = '../languages/lang.nl.php';
  break;

 case 'de':
  $lang_file = '../languages/lang.de.php';
  break;

  case 'en':
  $lang_file = '../languages/lang.en.php';
  break;

case 'australie':
  $lang_file = '../languages/lang.en.php';
  break;

case 'usa':
  $lang_file = '../languages/lang.en.php';
  break;

      default:
  $lang_file = '../languages/lang.nl.php';

  }
include_once '../languages/'.$lang_file;

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<style type="text/css">
    #drop-down-menu{margin-left:20px}
    ul{
        font-weight:bold;color:#ffffff;
        margin:0;
        padding:0;
        list-style:none}
    ul li{
        display:block;
        position:relative;
        float:left}
    li ul{display:none}
    ul li a{
        display:block;
        margin-left:1px;
        text-decoration:none;
        color:#ffffff;
        border-top:1px solid #B75963;
        padding: 5px 15px 5px 15px;
        background:#6E5463;
        white-space:nowrap}
    ul li a:hover{background:#985963;color:inherit}
    li:hover ul{ 
        display:block; 
        position:absolute}
    li:hover li{ 
        font-size:70%;
        clear:left; 
        width:20em}
    li:hover a{ background:#985963;color:inherit}
    li:hover li a:hover{background:#B75963;color:inherit}
    .clear_all{clear:both;height:0.2em;}
</style>

</head>
<body>

<div>
            <ul id="drop-down-menu">
                <li><a href="../index.php"><?php echo $lang['MENU_HOME']; ?></a></li>
                <li><a href="#"><?php echo $lang['MENU_CONTACT']; ?></a></li>
                <li><a href="#"><?php echo $lang['MENU_GUESTBOOK']; ?></a></li>
                <li><a href="#"><?php echo $lang['MENU_LINKS']; ?></a></li>  
                <li><a href="#"><?php echo $lang['LOGGEDIN-MENU_LOGIN']; ?></a>
                    <ul class="buttonBlock" >
                <li><a href="#" onClick="alert(' <?php $lang['ALERTBOX_A']; ?>')" ><?php echo $lang['LOGGEDIN-DROPDOWN-MY-ACCOUNT']; ?></a></li>
                <li><?php echo"<a href=\"#"; echo $lang['LOGGEDIN-DROPDOWN-EDIT-ACCOUNT']; ?></a></li>
                        <?php if($session->isAdmin())
                        {
                            echo "<li><a href=\"admin/admin.php\">"; echo $lang['LOGGEDIN-MENU_ADMIN_CENTER']; ?></a></li>
                            <?php
                        }
                       ?>
                    </ul>        
                </li>
                <li><?php echo "<a href=\"process.php\">"; echo $lang['MENU_LOGIN']; ?></a></li>
            </ul>

        </div>
        </body>
        </html>

lang.de.php

<?php
/* 
-----------------
Language: German
-----------------
*/

$lang = array();

$lang['ALERTBOX_A'] = 'Hierzu müssen Sie zunächst angemeldet sein.';

// Menu
$lang['MENU_HOME'] = 'Home';
$lang['MENU_CONTACT'] = 'Kontakt';
$lang['MENU_GUESTBOOK'] = 'Gästebuch';
$lang['MENU_LINKS'] = 'Links';
$lang['MENU_LOGIN'] = 'Anmelden';
$lang['LOGGEDIN-MENU_LOGIN'] = 'Anmelden';
$lang['LOGGEDIN-DROPDOWN-MY-ACCOUNT'] = 'Mein Account';
$lang['LOGGEDIN-DROPDOWN-EDIT-ACCOUNT'] = 'Mein Account bearbeiten';
$lang['LOGGEDIN-MENU_ADMIN_CENTER'] = 'Admin Center';

?>

lang.nl.php

    <?php
    /* 
    -----------------
    Language: Dutch
    -----------------
    */

    $lang = array();

    $lang['ALERTBOX_A'] = 'Hiervoor moet u ingelogd zijn.';

    // Menu
    $lang['MENU_HOME'] = 'Home';
    $lang['MENU_CONTACT'] = 'Kontakt';
    $lang['MENU_GUESTBOOK'] = 'Gasteboek';
    $lang['MENU_LINKS'] = 'Links';
    $lang['MENU_LOGIN'] = 'Aanmelden';
    $lang['LOGGEDIN-MENU_LOGIN'] = 'Aanmelden';
    $lang['LOGGEDIN-DROPDOWN-MY-ACCOUNT'] = 'Mijn Account';
    $lang['LOGGEDIN-DROPDOWN-EDIT-ACCOUNT'] = 'Mijn Account bewerken';
    $lang['LOGGEDIN-MENU_ADMIN_CENTER'] = 'Admin Center';

    ?>

lang.en.php

        <?php
        /* 
        -----------------
        Language: english
        -----------------
        */

        $lang = array();

        $lang['ALERTBOX_A'] = 'To do this, you must first be logged in.';

        // Menu
        $lang['MENU_HOME'] = 'Home';
        $lang['MENU_CONTACT'] = 'Contakt';
        $lang['MENU_GUESTBOOK'] = 'Guestebook';
        $lang['MENU_LINKS'] = 'Links';
        $lang['MENU_LOGIN'] = 'login';
        $lang['LOGGEDIN-MENU_LOGIN'] = 'Aanmelden';
        $lang['LOGGEDIN-DROPDOWN-MY-ACCOUNT'] = 'My Account';
        $lang['LOGGEDIN-DROPDOWN-EDIT-ACCOUNT'] = 'Edit my Account';
        $lang['LOGGEDIN-MENU_ADMIN_CENTER'] = 'Admin Center';

        ?>

Hope you can help me know
?

Thanks

Edited by johnnyd1963

0

If you want to see an example

goto Click Here

first choose your language with the flags on the upper left corner
then click login
Then mouseover the button acount then click on MY account

Edited by johnnyd1963

0

I found it by myself i had a forgot something i was forgotten to type the word ECHO
onClick="alert(' <?php $lang['ALERTBOX_A']; ?>')"

I changed in onClick="alert(' <?php echo $lang['ALERTBOX_A']; ?>')"

0

i saw just you missed the echo keyword for displaying the value

but you got it

thats great you found it yourself

Edited by radhakrishna.p: appreciating his knowledge

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.