Ben aşağıdaki kodu vardır:
<html>
<head>
<title><?php echo $GLOBALS['L']['title']; ?></title>
</head>
<body>
<ul id="language-selection">
<li><a href="index.php?lang=english">English</a></li>
<li><a href="index.php?lang=french">French</a></li>
</ul>
<h1><?php echo $GLOBALS['L']['h1']; ?></h1>
<p><?php echo $GLOBALS['L']['p1']; ?></p>
<ul id="language-selection">
<li><a href="about.php">About Page</a></li>
<li><a href="contact.php">Contact Page</a></li>
</ul>
</body>
</html>
set_locale.php:
<?php
/*
* File: set_locale.php
*/
// Get the language from the query string, or set a default.
($language = @$_GET['lang']) or $language = 'english';
// Set up a list of possible values, and make sure the
// selected language is valid.
$allowed_locales = array('english', 'french');
if(!in_array($language, $allowed_locales))
$language = 'english'; // Set default if it is invalid.
// Inlclude the selected language
include "locale/$language.php";
// Make it global, so it is accessible everywhere in the code.
$GLOBALS['L'] = $locale;
?>
It works OK, but if I click the about.php
and contact.php
link.
The page returns to the default language: English.
What can I do so that when I click about.php
or contact.php
ends up like this:
about.php?lang=english
contact.php?lang=french
respectively, in other words I want the URL to remember the ?lang=
ending.
What's the best way of doing it?