Page 1 of 1

Language switcher using directory/folder structure

Posted: Wed Feb 10, 2010 11:17 pm
by e11world
Hi all,
I've been looking on the net for something like this and found a few things but because I'm a beginner still, I can't put it together. :oops:
I need to change the site's language based on the folder /en/ or /fr/ only. The file names are always the same. The page should refresh when you hit the language text/image displaying the chosen language of the same page you were on. Example here http://www.contacservices.com/en/aboutus.html (when you click on the Français in the top right corner). It just changes the folder from en to fr and reloads/redirects the page. This works from any page except the home page which is because it's not within the en or fr folders.
The site is not big and this would work perfect and I don't think it uses sessions to do this either.

I have this code (included in every page) in ASP that does the job but not sure how to convert it into PHP:

Code: Select all

 
    <%
    Dim PATH_INFO
    PATH_INFO = Request.ServerVariables("PATH_INFO")
    If (Instr(PATH_INFO,"/fr/")>0) Then
       'Response.Write("FRENCH")
       PATH_INFO =Replace( PATH_INFO , "/fr/", "/en/")
    ElseIf (Instr(PATH_INFO,"/en/")>0) Then
       'Response.Write("ENGLSIH")
       PATH_INFO =Replace( PATH_INFO , "/en/", "/fr/")
    End If
    %>
    <%'Response.Write(Request.ServerVariables("PATH_INFO"))%>
    <div id="topslimbar"><a href="<%=PATH_INFO %>" target="_self" title="Passer au français">Français</a></div>
 
I also found this http://www.phpbuilder.com/tips/item.php?id=343 but it doesn't seem like what I need or it's just lacking detailed explanation. Maybe I'm just not using it right. :?
This is another place I thought was related but I'm a newbie and can't figure it out either http://www.phpfreaks.com/forums/index.p ... 82931.html

PLEASE HELP ME? :banghead:

Can you guys please help me?