What is the Best way to create a multi-language website with SEO in mind ? i google search and found someone using this code [QUOTE]$langs = array('fr','en'); session_start(); if(isset($_GET['l']) && in_array($_GET['l'], $langs)) { $_SESSION['lang'] = $_GET['l']; } else { $_SESSION['lang'] = 'en'; } header("Location: http://www.example.com/lang/index.".$_SESSION['lang'].".php"); exit; Now the links on your page would be something along these lines: <a href="index.php?l=fr">French</a> <a href="index.php?l=en">English</a> [/QUOTE] PHP: wonder how i can apply to my site ... Hope someone can enlight me Thank You
babelfish wont work ... it translate everything even my codes inside the form .. wanna do it manually and get ranked in foreign language also
one way to do it is to get your contents inside a database and write a page to crawl it. then call the google translate page with the url of the page for the translation. you can save the translation back to your tables in your database.
i dont want to use database ... i'm thinking this one is what i'm looking for ... but i dont really know how to use it ... do i have to use .htaccess redirect ? i want my visitor to have the ability to choose on it's own .. thanks in advance to people who reply <?php /** * index.php * multilingual website * lang/index.fr.php French translation * lang/index.en.php English translation * * @author Hatem <hatem@php.net> * @version 1.1.0 27 février 2002 */ /** * Detect and include language */ session_start(); if(!isset($lang)) { $lang = getenv('HTTP_ACCEPT_LANGUAGE'); $lang_default = "en"; } if (is_file("lang/index.$lang.php")) { $_SESSION["lang"] = $lang; include("lang/index.$lang.php"); } else { $_SESSION["lang"] = $lang_default; include("lang/index.$lang_default.php"); } /** * Then code your website here */ echo _HELLO_; echo "\n"._INFO_; ?> <?php /** * lang/index.en.php */ define("_HELLO_", "Hello"); define("_INFO_", "This web site support english and french"); ?> <?php /** * lang/index.fr.php */ define("_HELLO_", "Salut"); define("_INFO_", "Ce site web supporte l'anglais et le français"); ?> PHP:
No you don't need a redirect on your example. You just need to pass and capture the '$lang' variable from the page where the user choose from. e.g. <a href="yourlink?lang=en"></a> Also change the if(!isset($lang)) { to something like if(!isset($_GET['lang'])) { <--- this will capture the 'lang' variable from the url link. On you example, it is displaying a different page depending on their browser language.
Yup. I recommend using gettext for the actual multi-language part. Actually, I'd recommend doing it anyway just to separate content from code. So instead of having: echo 'This is my text.'; PHP: You'd have: echo _('This is my text.'); PHP: Not much more work, but a lot of benefits further down the road.
hi ... vonvhen and roy.laurie .. thanks for the reply ... i like the idea you both gave ... but since i dont have much php programming knowledge .. i dont know how i can apply these codes to my site :-S
Unless you learn some basic programming skill, your best way would be to use HTML and static pages. just name your pages with a different name and link to it on your main page.