Question

I have another question about LANGUAGE switching... I've searched a solution but I did not find it, so here I am...

I have this code to switching language on my website (thanks to your help!!):

<?php if($lang['LINGUA'] != 'Italiano') { ?>
   <li><a href="index.php?lang=it"><img class="iclflag" src="assets/images/flags/it.png" alt="Italiano"> Italiano</a>
   <?php } if($lang['LINGUA'] != 'Francais') { ?>
       <li><a href="index.php?lang=fr"><img class="iclflag" src="assets/images/flags/fr.png" alt="Francais"> Fran&ccedil;ais</a></li>
    <?php } if($lang['LINGUA'] != 'English') { ?>
       <li><a href="index.php?lang=en"><img class="iclflag" src="assets/images/flags/en.png" alt="English"> English</a></li>
 <?php } ?>

Now suppose I am on the "contact" page in Italian and I switch to English. The site returns me on the homepage, in English. I would like, instead, that it remains on the contact page.

Is that possible in any way..? It is possible to switch language on one page remaining on that same page?

Secondly, the url of the page remains always, for every language (for example) www.mysite.it/contact.php Is it possible to specify the language in the url, for every page?

I hope I was clear enough in my questions...

Thank you in advance for your help!

Francesca

Was it helpful?

Solution

try this:

<?php if($lang['LINGUA'] != 'Italiano') { ?>
   <li><a href="<?=$_SERVER['PHP_SELF']?>?lang=it"><img class="iclflag" src="assets/images/flags/it.png" alt="Italiano"> Italiano</a>
   <?php } if($lang['LINGUA'] != 'Francais') { ?>
       <li><a href="<?=$_SERVER['PHP_SELF']?>?lang=fr"><img class="iclflag" src="assets/images/flags/fr.png" alt="Francais"> Fran&ccedil;ais</a></li>
    <?php } if($lang['LINGUA'] != 'English') { ?>
       <li><a href="<?=$_SERVER['PHP_SELF']?>?lang=en"><img class="iclflag" src="assets/images/flags/en.png" alt="English"> English</a></li>
 <?php } ?>

OTHER TIPS

Just do the menu associations, you need to do for each menu.. and It would work as expected

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