How to trigger site language change using php?
<p>I am making a site, using only PHP as back-end (no framework), which should be available in 3 languages. The site structure (tables/divs) is maybe less common. It tends to simulate an Ajax kinda behavior. I include a file (selector.php) in the body, which takes care of it's content, via _GET(), passed from the navigation links. This means, that the site actually never leaves index.php. The languages are links (flags).  </p>

<p>Now, I did managed to implement successfully the 3 languages (arrays/session/cookie), and it does work. However, what I need is to be able to make the language selection to stay/refresh the same page from where it was called. Here it becomes tricky, since I am using only one page, every include/subsequent includes (30+) are called from the index.php, so using the <code>header ('Location: ...')</code> seems not to be an option. 
I know how to retrieve my current address, including the GET parameter, so I could use it. But how? Reading it at the beginning of the code, then re-read in the language module does match at any given point. There is a session, so I could also use session variables, but making 35+ variables for the content (so url changes) and match them all the time, does not seem to be the right method. Where, and more precisely how to catch the language change, and how to refresh/redirect to the "same page" for the changes to take effect? It could be a design flow.  </p>

<p>Note 1: Using <strong>mod_rewrite</strong> I redirected my language query, so now instead of <code>mysite.com/index.php?lang=en</code>, it's in form of <code>mysite.com/en/index.php</code> so I can use more friendly links to call the body content.<br>
Note 2: I passed the last week reading/searching here/anywhere Google leads, trying countless times different approaches, none of them worked as expected (maybe concept flow?!).<br>
Note 3: Since this is for a client, who explicitly asked not to use Java at all, please don't give Ajax/jQuery/Java solutions (with those, I would know how to do).<br>
Note 4: The whole code is rather large to paste here, so if you need to see different parts, name them, and I'll edit my question.<br>
Note 5: I still retain myself as a beginner, so please bear with me.  </p>

<p>Thanks in advance.  </p>

<p>So the language selector looks like that:  </p>

<pre><code>    session_start();
    header('Cache-control: private'); // IE 6 FIX
    if(isSet($_GET['lang'])) {
        $lang = $_GET['lang'];
        $_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 = 'ro'; }

    switch ($lang) {
    case 'en': $lang_file = 'lang.en.php'; break;
    case 'it': $lang_file = 'lang.it.php'; break;
    case 'ro': $lang_file = 'lang.ro.php'; break;
    default: $lang_file = 'lang.ro.php'; break; }

    include_once 'languages/'.$lang_file; 
</code></pre>

<p>Then the selector... </p>

<pre><code>    function isValidPage($cont) {
     $validpages = array("history","mission","etc");
     if(in_array($cont,$validpages) &amp;&amp; file_exists(ltrim($cont,'/') . '.php')) {
          return TRUE; } 
    else {
          return FALSE; }
    }

    if(isset($_GET['cont']) &amp;&amp; isValidPage($_GET['cont'])) {
        @include($_GET['cont'] . '.php'); } 
    else {
        @include('sub_index.php'); }  
</code></pre>

<p>I start my index.php with:  </p>

<pre><code>      &lt;?php include_once 'lang_sel.php'; ?&gt; 
    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;title&gt;mysite&lt;/title&gt;
    &lt;link rel="stylesheet" href="style/css.css" type="text/css" /&gt;   

&lt;/head&gt;
&lt;body&gt;
    &lt;div class="parent"&gt;
        &lt;div class="left"&gt;&lt;?php include("main/left_main.php"); ?&gt;&lt;/div&gt;
        &lt;div class="right"&gt;
            &lt;div class="topmain"&gt;&lt;?php include("main/top_main.php"); ?&gt;&lt;/div&gt;
            &lt;div class="dummyx"&gt;&lt;/div&gt; &lt;!-- dummy div for adjusting starting position --&gt;
            &lt;div class="rightall"&gt;
                &lt;?php include("main/top_nav.php"); ?&gt;
                &lt;?php /*include("main/top_rotator.php"); */?&gt;
                &lt;table width="780" border="0" cellpadding="10px" cellspacing="0" bgcolor="transparent" id="middle"&gt;&lt;?php include ('selector.php'); ?&gt;&lt;/table&gt; &lt;!-- container for the main content --&gt;
            &lt;/div&gt;       
            &lt;div class="footer"&gt;
                &lt;?php include("main/bottom.php"); ?&gt;
                &lt;?php include("main/footer.php"); ?&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="clr"&gt;&lt;/div&gt; &lt;!-- clearing div attributes --&gt;
    &lt;/div&gt;  
</code></pre>

<p>Then the left side contains the flags:  </p>

<pre><code>&lt;tr&gt;
    &lt;td width="30"&gt;&amp;nbsp;  &lt;/td&gt;
    &lt;td width="63" align="center" valign="middle"&gt;&lt;span class="lang"&gt;&lt;a href="&lt;?=WEBROOT?&gt;ro/index.php" title="Romana"&gt;&lt;img src="images/flags_ro.jpg" alt="ro" name="Romana" width="35" height="40" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td width="63" align="center" valign="middle"&gt;&lt;span class="lang"&gt;&lt;a href="&lt;?=WEBROOT?&gt;en/index.php" title="English"&gt;&lt;img src="images/flags_en.jpg" alt="en" name="English" width="35" height="40" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td width="63" align="center" valign="middle"&gt;&lt;span class="lang"&gt;&lt;a href="&lt;?=WEBROOT?&gt;it/index.php" title="Italiano"&gt;&lt;img src="images/flags_it.jpg" alt="it" name="Italiano" width="35" height="40" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;td width="30"&gt;&amp;nbsp;  &lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>Also the menu, which is a bunch of lists like:  </p>

<pre><code>        &lt;ul class="menu"&gt;   
            &lt;li&gt;&lt;a href="index.php?cont=history" style="background:none"&gt;&lt;?php echo $lang['MENU_HISTORY']; ?&gt;&lt;/a&gt;&lt;!--&lt;div&gt;&lt;span&gt;if you want to add 'sub-content' put it here&lt;/span&gt;&lt;/div&gt;!--&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="index.php?cont=mission" style="background:none"&gt;&lt;?php echo $lang['MENU_MISSION']; ?&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="index.php?cont=p_systems" style="background:none"&gt;&lt;?php echo $lang['MENU_P_SYSTEM']; ?&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="index.php?cont=s_dist" style="background:none"&gt;&lt;?php echo $lang['MENU_S_DIST']; ?&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
</code></pre>

<p>The content is simple, text and images. So the main code is above...</p>
