Question

My site is structured in the following way:

index.php

  • fileA.php
  • fileB.php
  • fileC.php
  • ecc.

Each of this files have associated 3 language files (english, german and italian), stored in a folder. The languages are changing dynamically with an select menu:

<form name="switch_menu" id="lang" action="" method="post">
<select name="lingua" class="switch" onchange="this.form.submit()">
<option value="lang_it" <?php if($lang == "lang_it"){ echo "selected=\"selected\""; }?>>Italiano</option>
<option value="lang_de" <?php if($lang == "lang_de"){ echo "selected=\"selected\""; }?>>Deutsch</option>
<option value="lang_en" <?php if($lang == "lang_en"){ echo "selected=\"selected\""; }?>>English</option>
</select>
</form>

and the code in the files is this one:

switch($lang){
case 'lang_it': include_once('folder/it/fileA.it.php'); break;
case 'lang_de':  include_once('folder/de/fileA.de.php'); break;
case 'lang_en':  include_once('folder/en/fileA.en.php'); break;
default: include_once('folder/en/fileA.en.php'); break;
 }

where fileA.en.php,fileA.it.php and fileA.de.php are the language content.

Is it possibile to manipulate the second part of the code with some if statement or similar, so the selected language is shown in the url? Otherwise the search engines won't see the other languages (italian and german). Otherwise can i add some code to achieve the purpose?

Thanks in advance for any hints.

No correct solution

OTHER TIPS

Why not just using GET instead of POST in the form? That will put the $lang variable in your URL, something like http://yourdomain.com/fileA.php?lang=it

Then, for the crawler to look at the different languages more efficiently, you could make internal links to the site using the URL with the lang GET variable.

Also, take a look at Gettext, it is a much better way to implement internationalization.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top