Forum Moderators: phranque

Message Too Old, No Replies

Change Site Language without leaving current page

change language of a site using SSI without leaving current page

         

G WebServices

2:55 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



I have flag buttons on my site that people can click on in order to switch languages. For easy updating purposes I use SSI (server side includes) in order to modify the language code from one simple external .txt file.

My problem: People who click on a language flag are forced to visit the index file (start page) for each language.

My question: I want to create a link that will 1. Grab my current url 2. add or change the language subfolder to the url without modifying the rest of the current url.

This will allow visitors to stay on the same page but in a different language.

For example. If I'm on a car specific page and the url is:

www.example.com/topics/cars/porche.html

I want readers to be able to click on the Brazilian flag but be taken to the same link but have the /port/ file added to the url:

www.example.com/port/topics/cars/porche.html

Question. Can I create a JavaScript link or something that allows me to use my SSI file to take visitors to specific language sections with the same URL as the previous language?

Here's my SSI file:

<!--Change Language Div -->
<div id="language">
<a href="http://www.example.com/index.html" title="Espa&ntilde;ol"><img src="images/spanishFlag.gif" alt="Spanish Flag" title="Change language to Spanish"></a>
<a href="http://www.example.com/eng/index.html" title="English"><img src="images/english.gif" alt="British Flag" title="Change Language to English"></a>
<a href="http://www.example.com/port/index.html" title="Portuguese"><img src="images/portuguese.gif" alt="Brazilian Flag" title="Change Language to Portuguese"></a>
</div>
<!--End Change Language Div-->