Note that there are some explanatory texts on larger screens.

plurals
  1. POManually Changing Languages
    primarykey
    data
    text
    <p>I've got a website where the country is detected automatically and a language is set according to the country, but the users have no manual way to change it.</p> <p>How can I add the following code to the code below it to make sure I can enter the following link: <a href="http://example.com/index.php?lang=de" rel="nofollow">http://example.com/index.php?lang=de</a></p> <pre><code>//Code I want to integrate with the code below switch ($lang) { case 'en': $lang_file = 'lang.en.php'; break; case 'de': $lang_file = 'lang.de.php'; break; default: $lang_file = 'lang.en.php'; } //Main Code Below &lt;?php function visitor_country() { $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; $result = "Unknown"; if(filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif(filter_var($forward, FILTER_VALIDATE_IP)) { $ip = $forward; } else { $ip = $remote; } $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip)); if($ip_data &amp;&amp; $ip_data-&gt;geoplugin_countryName != null) { $result = $ip_data-&gt;geoplugin_countryName; } return $result; } session_start(); header('Cache-control: private'); // IE 6 FIX if (isSet($_GET['lang'])) { $lang = $_GET['lang']; // register the session and set the cookie $_SESSION['lang'] = $lang; setcookie('lang', $lang, time() + (3600 * 24 * 30)); } else if (isSet($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else if (isSet($_COOKIE['lang'])) { $lang = $_COOKIE['lang']; } else { $lang = 'en'; } if(visitor_country() == "Germany") { $lang_file = 'lang.de.php'; //echo "Germany"; } else { $lang_file = 'lang.en.php'; //echo "Not in Germany"; } include_once 'languages/' . $lang_file; ?&gt; </code></pre> <p>Any Suggestions?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload