March 16, 200917 yr I am working on a bilingual site which has one folder for english site and another for the second language (welsh). The two folders are mirrors of eachother so all the files names are the same, just with a different folder name ie. english/contact.php welsh/contact.php The navigation that switches from one language to another is a php include but I'm not sure how to create it so that, when clicked, the 'welsh' link takes my visitor from one page to the equivalent page in the welsh folder. I currently do this with a static html navigation and hard code each link seperately but really need to make this work dynamically. Can anyone help me out here? many thanks
March 16, 200917 yr How about <a href="<?php echo str_replace('/english/', '/welsh/', $_SERVER['PHP_SELF']) ?>">Welsh</a> <a href="<?php echo str_replace('/welsh/', '/english/', $_SERVER['PHP_SELF']) ?>">English</a> Then, if it's on the English page, the str_replace won't do anything, so the English link will be to self. And vice-versa.
March 16, 200917 yr How about <a href="<?php echo str_replace('/english/', '/welsh/', $_SERVER['PHP_SELF']) ?>">Welsh</a> <a href="<?php echo str_replace('/welsh/', '/english/', $_SERVER['PHP_SELF']) ?>">English</a> Then, if it's on the English page, the str_replace won't do anything, so the English link will be to self. And vice-versa. That's pretty much the exact answer I was going to give you!
March 16, 200917 yr Author How about <a href="<?php echo str_replace('/english/', '/welsh/', $_SERVER['PHP_SELF']) ?>">Welsh</a> <a href="<?php echo str_replace('/welsh/', '/english/', $_SERVER['PHP_SELF']) ?>">English</a> Then, if it's on the English page, the str_replace won't do anything, so the English link will be to self. And vice-versa. Thanks so much, and for being so quick! One day I will learn php but it's so hard to know where to start!! diolch yn fawr (thanks very much in welsh!)
Create an account or sign in to comment