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!