Jump to content

imop

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

imop's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. That means i need to define array to all languages i have? I tried do put the script, you wrote, in language.php, but this is not working also for images i`m confused I think it wont be the case... $languages = array('lv' => 'Latviešu', 'en' => 'English', 'ru' => 'Russian'); Because the $language give the language name down to next step of script who is responsable for LINK on language switcher: // As one last step, create a function // that can be used to output language // options to the user: function switch_language_options() { // Include a few globals that we will need: global $text, $languages, $lang; // Start our string with a language specific // 'switch' statement: // $retval = $text['switch']; // Loop through all possible languages to // create our options. $get = $_GET; foreach ($languages as $abbrv => $name) { // Create the link, ignoring the current one. if ($abbrv !== $lang) { // Recreate the GET string with // this language. $get['lang'] = $abbrv; $url = $_SERVER['PHP_SELF'] . '?' . http_build_query($get); $retval .= " <a href=\"{$url}\"> {$name}</a>"; } } // Now return this string. return $retval; }
  2. Greeting to you all! I`m a real newbie at php please help... :-\ I have a problem: i don`t know how to define an image (Language flag) to display insted of text so he re is the code: language.php <?php // This is a library, that by including it, // automatically determines the proper language // to use and includes the language file. // First define an array of all possible // languages: $languages = array('lv' => 'Latviešu', 'en' => 'English', 'ru' => 'По Русски'); // Look at the GET string to see if lang is // specified: if (isset($_GET['lang'])) { // It's been specified, so set the language $lang = $_GET['lang']; // While here, send a cookie to remember this // selection for 1 year. setcookie('lang', $lang, time()+(3600*24*365)); } // Ok, otherwise look for the cookie itself: elseif (isset($_COOKIE['lang'])) { // Use this $lang = $_COOKIE['lang']; } else { // Otherwise, default to English $lang = 'lv'; } // Make sure that the language string we have is // a valid one: if (!(in_array($lang, array_keys($languages)))) { die("ERROR: Bad Language String Provided!"); } // Now include the appropriate language file: require_once "languages/{$lang}.php"; // As one last step, create a function // that can be used to output language // options to the user: function switch_language_options() { // Include a few globals that we will need: global $text, $languages, $lang; // Start our string with a language specific // 'switch' statement: // $retval = $text['switch']; // Loop through all possible languages to // create our options. $get = $_GET; foreach ($languages as $abbrv => $name) { // Create the link, ignoring the current one. if ($abbrv !== $lang) { // Recreate the GET string with // this language. $get['lang'] = $abbrv; $url = $_SERVER['PHP_SELF'] . '?' . http_build_query($get); $retval .= " <a href=\"{$url}\"> {$name}</a>"; } } // Now return this string. return $retval; } ?> I know that i need to change this part: // First define an array of all possible // languages: $languages = array('lv' => 'Latviešu', 'en' => 'English', 'ru' => 'По Русски'); This is on of my language files: lv.php <?php // Visi teksti kuri nepieciešami lapas darbībai, // Latviešu valodā. $GLOBALS['text'] = array ( 'title' => 'v0.1 LV', 'lv' => 'Latviešu' ); // Define text as image $GLOBALS['imgsrc'] = array ( 'lv' => 'img/karogi/lv.gif' ); ?> How do i insert this in to - language.php to display flags instead of text? Thx!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.