FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


managing a bilingual site





davmcmul
I am currently trying to manage my bilingual site a little better. Currently, the content of both languages is contained in the same page and I use sessions to decide which content is shown to the user. I would like to use cookies instead because i am told that sessions are insecure and they do not validate with the w3c validator (i used to be proud of having all valid html....). I have been learning about using cookies in php and my main problem is that a cookie can only be set before the html of a page is called. The problem, it would seem, is getting the user to make the choice between the two languages (in my case irish and english). Because i can't (as far as i can see) have them click on a link and have the cookie set accordingly. The best idea i have come up with is a page with two links, one to my irish redirect page and another to my english redirect page. The irish redirect page would set the cookie to irish before redirecting the user to my homepage while the english redirect page would set the cookie to english before redirecting the user to the homepage. I would prefer not to use this method as it seems messy to me so I am asking here to see if there is some better way. Also I would like to know if it is possible to set a cookie for an infinite length of time instead of a year, month or day as there is no real reason for this cookie to expire and (this one may seem a little obvious) can the value of a cookie bechanged without destroying that cookie and making a new one? Also what is the code to for a redirect after a certain function has been executed (as opposed to after a certain amount of time).

Thank you for all your help in advance and please feel free to voice any idea to handle the matter, even staying with sessions, I value your oppinion Wink

Thanks
izcool
I would suggest this to you.

Make a cookie that stores the Language that they want to see the site in. If that cookie is not set when they get to your initial site, redirect them to the "Choose Language" page where they have to choose one in order to go and see the rest of the site with. Have an option on every other page to change languages (in case if someone chose the wrong option, for some unknown reason why) and I think that would work the best.

Hope it works out for you. Smile

- Mike.
davmcmul
izcool wrote:
I would suggest this to you.

Make a cookie that stores the Language that they want to see the site in. If that cookie is not set when they get to your initial site, redirect them to the "Choose Language" page where they have to choose one in order to go and see the rest of the site with. Have an option on every other page to change languages (in case if someone chose the wrong option, for some unknown reason why) and I think that would work the best.

Hope it works out for you. Smile

- Mike.


I agree, however, this is trickier than it might first seem (or i am just denser than i might first seem) because with php cookies can only be set before any html, so how do i manage this choose language page, it which i want to set a cookie depending on what the user selects, but the cookie has to be set before this selector.......or on another page.
izcool
Not necessarily. I programmed on a few sites before where I can set cookies wherever I want to. You might just need to fiddle with the code to make it work properly. Smile

- Mike.
davmcmul
I have in fact achieved my goal. I now have a drop down list on each page giving the user the choice between languages. I inserted the following code into every page:

<form action="langswitcher.php" method="post">
<select name="set">
<option value="en">English</option>
<option value="ga">irish</option>
</select>
<input type="submit" value="Change Language">
</form>

and the following code was in the file langswitcher.php:

<?php
setcookie ('lang', $set, time()+31536000, '/', 'davidmcmullin.frihost.net', '0');
header("Location: $HTTP_REFERER");
?>
and voila, i didn't even have to change anything else, i just kept the variable name the same and it was an easy switch between sessions and cookies. I'm so happy.
izcool
Congratulations on your accomplishment with that. Smile

- Mike.
Related topics
site theme
What's Your site About
Un-Official Ask Bondings Something Thread
mambo
[RESOLVED]Does anyone know how to block a specific site...
[official] Feedback for the Frihost Staff
May I request permission to have music on my site?
Wanted - D/Weaver template+CSS *$negotiable*
Fighters for Glory - clan website
Fainte Networks - Multiple Site Listings
A project manager site
Help coding myspace layouts for my site?
Site not opening everywhere
7 years of Frihost
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.