imop
-
Posts
30 -
Joined
-
Last visited
Posts posted by imop
-
-
Cenšos apgūt vairāku valodu funkciju vienā lapā, tamdēļ parakos google un atradu vienu man piemērotu variantu ar kuru varētu darboties, bet visu laiku met ārā vienu problēmu ka nav pareizi definēta
funkcija - function switch_language_options()
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('en' => 'English', 'fr' => 'French', 'de' => 'German'); // 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 = 'en'; } // 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 "{$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; } ?>
HELP!
-
Šitā kaut kā?
<a href="#"><img src="tree_<?php echo $va; ?>.jpg" /></a>
Un tad jāsataisa trīs bildītes:
tree_en.jpg, tree_ru.jpg un tree_lv.jpg
Liels paldies!
-
Jopcik popcik, tu katru tekstu savai valodai taisi? Klau, ja nav noslēpums - taisi komerpasūtījumu vai savu projektu?
Izpaliidzu comam kuram lapa ir tad nu ciinamies abi galvas salikushi!
Vienkaarshi to lapu senum sen saveidoja vinjam tad nu tagad mazliet jaapielabo utt izdomaajaam pacakareeties.
-
Lapai ir trīs valodas viss skaisti straadaa utt, bet gribu lai teksta vietaa raadiitos bilde katrai valodai, nemaaku uztaisiit, neesmu PHP specs. bet iesaaceejs
gribaas arii taa lai links buutu iekhaa!
<?php switch ($va){ case "lv": echo("Koks"); break; case "ru": echo("Дерево"); break; case "en": echo("Tree"); break; } ?>
Paldies jau ieprieksh!
Lapa ar vairākām valodām
in Iesācējiem
Posted
Piemirsu ierakstīt erorr:
tad nu: Parse error: syntax error, unexpected T_FUNCTION in /var/www/HOSTINGS/MACIBU/language.php on line 41