Language selection

Discussion in 'Programming/Scripts' started by bernholdt, Nov 30, 2008.

  1. bernholdt

    bernholdt Member

    Hi
    Im working on some language selection in a website, so far it is working wery well exept i cant get it to remember the chosen language when changing pages, im thinking it must be done by either using a session or a cookie but im stuck atm.

    Here is my code.
    PHP:
    <?php 
    //language
    $languages = array(     
        
    'en' => 'english'
        
    'dk' => 'danish'
        ); 

    if (isset(
    $_GET['lang']) AND array_key_exists($_GET['lang'], $languages)) 

        include 
    './lang/' $languages[$_GET['lang']] . '.php'

    else 

        include 
    './lang/english.php'


    ?>
    And to change the language im just using simple links
    PHP:
    <a class="link" href="<? echo $_SERVER[PHP_SELF];?>?lang=dk"><?php echo $lng['danish']; ?></a>

    <a class="link" href="<? echo $_SERVER[PHP_SELF];?>?lang=en"><?php echo $lng['danish']; ?></a>
    Any ideas ??
     
  2. falko

    falko Super Moderator Howtoforge Staff

Share This Page