I was looking hard and low on the web today for a quick way to create a button to dynamically switch from an English to a French page using ASP. Well I couldn’t find one, so I wrote a short little function that seems to do the trick.

In a separate file copy and paste the following code:


Function SwitchtoFrench(FullPath)
FullPathFrench=replace(FullPath,”english”,”french”)
End Function %>

What this little function does is take the full path of the page you are currently on and switch out the word “english” for “french” and a new variable is created. We are assuming that we are keeping the exact same directory structure and naming convention for your second language site. So when you swap the English for French it should be an easy swithc.

Now, save this file as, for example, switchtofrench.inc and save it in your includes folder. Now go to your asp page that contains your french link and copy and paste the following <a href> tag.

<a href=”<% = SwitchtoFrench(Request.ServerVariables(“PATH_INFO”)) %>”>

And don’t forget to add the following code to the first line of your asp page:

<!–#include file=”../includes/switchtofrench.asp”–>

And you should be good to go!