My website has two languages: French and English. The solution I chose is working but is causing me trouble. I use session in order to keep a "clean" url which is the same in English and in France.
My solution:
To choose the language, I locate the user using IP, and if it is not in France, i set
$_SESSION['language'] = "ENG"
Otherwise,
$_SESSION['language'] = "FRA"
Then I includes my file words.php which contains all the text like this:
if( $_SESSION['language'] == "ENG")
{
$word1 = "hello"
$word2 = ....
}
else
{
$word1 = "bonjour"
$word2 = ....
}
Finally on my website, I have several echo $word1;
.
To change language, I have a two links (one for each language) to a webpage language.php with a get parameter that just change the session variable and redirect to the webpage:
if($_GET['l']=="1")
{
$_SESSION['language'] = "FRA";
header('Location: ' . htmlspecialchars($_SERVER['HTTP_REFERER']));
}
elseif($_GET['l']=="2")
{
$_SESSION['language'] = "ENG";
header('Location: ' . htmlspecialchars($_SERVER['HTTP_REFERER']));
}
My problem: My main problem is that Google is indexing my website only in English ( guess because the IP of crawler is not in France?). In google.fr and google.com, my website is in English. What can I do to have the website indexed in both languages?