I have a small site setup in both english and french. Both language content is on the same page... there is just an include to set a session variable to either "eng" or "fr" and then the page grabs the appropriate content depending on which language was selected.
Here is basically how it's setup.
There is an inital splash page to select your language... then the language is set.
There is an include is in every page to check what language to display.
To switch languages, there is a button to a language switch page, that changes it to either english or french.
F or some reason the language select will notwork all the time.. just sometimes it seems. And sometimes I will have to click the "langaugage selection" link twice to switch languages. The code is below... but I'm wondering if there is a simpler way to do this, or maybe modify the existing code to have it function properly. Any help is greatly appreciated!
Language Selection Page
(sets the language initially) - there is an eng and fr page... both pages are the same exept one sets "eng" and one sets "fr"
<%
String langChoice = "eng";
session.setAttribute( "langPref", langChoice );
%>
Every page has this include in it which checks the language for "eng" or "fr"
<%
String langChoice = request.getParameter( "lang" );
if ( langChoice == null )
session.setAttribute( "langPref", session.getValue("langPref") );
else if ( langChoice.equals("fr") && session.getValue("langPref") == "eng" )
session.setAttribute( "langPref", langChoice );
else if ( langChoice.equals("eng") && session.getValue("langPref") == "fr" )
session.setAttribute( "langPref", langChoice );
else if ( langChoice.equals("fr") )
session.setAttribute( "langPref", "fr" );
else
session.setAttribute( "langPref", "eng" );
%>
Every page has a button to switch the language.
<%
String langChoice;
if (session.getValue("langPref") == "eng")
langChoice = "fr";
else
langChoice = "eng";
session.setAttribute( "langPref", langChoice );
%>
Thanks.
Albert