xcoderx Posted May 13, 2010 Share Posted May 13, 2010 i got this coding below, how and what would be the best way to use it to my site without affecting seo and along with exsisting logged in user data? how would you do it? <?php session_start(); header('Cache-control: private'); // 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'; } switch ($lang) { case 'en': $lang_file = 'lang.en.php'; break; case 'de': $lang_file = 'lang.de.php'; break; case 'es': $lang_file = 'lang.es.php'; break; default: $lang_file = 'lang.en.php'; } include_once 'languages/'.$lang_file; ?> Quote Link to comment Share on other sites More sharing options...
ignace Posted May 14, 2010 Share Posted May 14, 2010 Create your website as if you were to create it in ONE language. Afterwards translate it using a SINGLE database table. translations (key, message) <a href="#"><?php print _('Login'); ?></a> Shows Login for English (default language), Aanmelden for Dutch, .. Quote Link to comment Share on other sites More sharing options...
xcoderx Posted May 14, 2010 Author Share Posted May 14, 2010 is it necessary to use database or its ok to store the languages in a variable? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 14, 2010 Share Posted May 14, 2010 is it necessary to use database or its ok to store the languages in a variable? It would be better if you used a database as you inevitably will end up using one. Remember: those files in which you store your data (eg XML) is also a database. This has the advantage that you don't have multiple sources that hold translation data. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.