July 24, 201313 yr Hi guys! How are you ? =D I wanna do something for my website could you help me please ? I wanna make my website Multilangual, I mean I wanna make the index of my website as a page that the visitor chose in your langage ( between 3 languages) when he clicks on his language he's gonna enter the website..so how can I do it ?
July 24, 201313 yr Easiest way to do it would be to have the different files and put them in a lang/ directory in this example im going to use the folowing lang.en.php - English lang.de.php - German lang.es.php - Spanish In these file have a setup like so, change the values for the language needed $lang = array(); $lang['Nav_link_home'] = 'Home'; $lang['Nav_link_about'] = 'About'; $lang['Nav_link_contact'] = 'Contact'; $lang['Nav_link_Other'] = 'Other'; Somewhere on your page have a link to the diffrent languages <a href="lang.php?lang=en">English</a> | <a href="lang.php?lang=de">German</a> |<a href="lang.php?lang=es">Spanish</a> Now for the php to select the language, call this lang.php <?php session_start(); if ($_GET['lang']) { $lang = str_replace('.', '', $_GET['lang']); if (file_exists('lang/lang.'.$lang.'.php')) { $_SESSION['lang'] = $lang; } } ?> Now for selecting the language in the browser, just place this code in the part of your website that needs to be multi lingual <?php // Suppress the session_log if its already called @session_start(); if ($_SESSION['lang']) { $lang = $_SESSION['lang']; } else { // Set default to english if they have not selected a language yet $_SESSION['lang'] = 'en'; $lang = $_SESSION['lang']; } require_once('lang/lang.'.$lang.'.php'); ?> Now to print the text use sometthing like these echo $lang['Nav_link_home']; echo "<a href='#'>".$lang['Nav_link_home']."</a>"; <?php echo $lang['Nav_link_home']; ?> Edited July 24, 201313 yr by D4Y0
July 24, 201313 yr Hi Ismael! There are some aspects which you should keep in mind while making your site multilingual. You can try to use Unicode – it provides a unique number for every character and works with all platforms, programs and languages. I will help you a lot to adapt your site to many languages. Also don't forget to adapt your content – work with localization and optimization. Good luck!
July 25, 201313 yr Author Hi Ismael! There are some aspects which you should keep in mind while making your site multilingual. You can try to use Unicode – it provides a unique number for every character and works with all platforms, programs and languages. I will help you a lot to adapt your site to many languages. Also don't forget to adapt your content – work with localization and optimization. Good luck! Thank you brother but I can change the whole website to another language but this is not the problem.. the problem is that I wanna make my home page as a simple page that you chose in your language, when you chose it, the website gonna run with the same language that you selected ..
Create an account or sign in to comment