Français"; $link_english = "English"; $link_logoff = "Logoff"; # Set $getlang to the requested key for the language if a GET arg 'lang' exists. $getlang = $_GET['lang']; # Set a cookie to the GET arg 'lang' if it exists. # Set the SESSION key 'lang' to the 'lang' value of the cookie if it exits. if ( $use_cookie == 1 ) { if ( isset ($getlang) ) { setcookie ('lang', $getlang, expire_cookie); } if ( isset ($_COOKIE['lang']) ) { $_SESSION['lang'] = $_COOKIE['lang']; } } # Destroy session and cookie. if ( isset ($_GET['logoff']) ) { session_destroy (); if ( $use_cookie == 1 ) { setcookie ('lang',$getlang, -3600); } header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/" . $PHP_SELF); } # The main routine. # It expect an array for argument: ('lang1', 'string', 'lang2', string'). function setstring () { global $defaultlanguage; global $getlang; $lang = $_SESSION['lang']; $args = func_get_args (); # A newcomer. if ( !isset ($lang) ) { session_register ('lang'); $lang = $defaultlanguage; } # give $_GET['lang'] the choice to set $lang if ( isset ($getlang) ) { $lang = $getlang; $_SESSION['lang'] = $lang; } # Now $lang have been set either by $languagedefautl, $getlang, or $_SESSION['lang']. # Loop in the language array and return $string if $lang is found. if ( count ($args) ) { if ( in_array ($lang, $args) ) { for ($i = 0; $i < count ($args); $i++) { if ( $args[$i] == $lang ) { return $args[$i + 1]; } } } } return ""; } ?>