title: Including a wp-lang file to define WPLANG according to user's choice (Wordpress)?
body: <p>In this <a href="https://stackoverflow.com/questions/3611703/how-to-change-the-value-wplang-in-wordpress-by-clicking-a-link-switch-language">previous questions</a>, someone told me how to make WPLANG clickleable, so that the user can choose his preferred language (usually you can only define WPLANG by modifying the wp-config). But I'm sure how to make the link. Are the following functions giving me the possibility of using <code>example/?lang=</code> Or <code>example/en</code>?  </p>
  
  <p>*wp-lang.php</p>
  
  <pre><code> session_start();
   if ( isset( $_GET['lang'] ) ) {
      $_SESSION['WPLANG'] = $_GET['lang'];
      define ('WPLANG', $_SESSION[WPLANG]);
   } else {
      if(isset($_SESSION['WPLANG'])) {
          define ('WPLANG', $_SESSION['WPLANG']);
          $_GET['lang'] = $_SESSION['WPLANG'];
      } else {
          if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ) {
              $languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] );
               $languages = explode( ",", $languages );
              $_SESSION['WPLANG'] = $languages[0];
              $_SESSION['WPLANG'] = str_replace("-", "_", $_SESSION['WPLANG']);
              $_GET['lang'] = substr($_SESSION['WPLANG'],0,2);
              define ('WPLANG', $_SESSION[WPLANG]);
          } else {
              define ('WPLANG', '');
          }
      }
   }
  </code></pre>
  
  <p>*wp-config.php - Find the section where the constant WPLANG is defined. Add in the following line just before the WPLANG declaration.</p>
  
  <pre><code> require_once(dirname(__FILE__).'/wp-lang.php');
   define ('WPLANG', ''); 
  </code></pre>