January 17, 201313 yr Hello How do I write a script in php that will redirect to within a certain folder structure... basically if I have an english site - www.example-site.com and a spanish version of the site within the subfolder www.example-site.com/spanish/ and a german in www.example-site.com/german how do I create a script that will say go to the same page but in the german site. So if they are on a page in english site but an earlier script recognises they have german set as their browser language how can I make it redirect to the equivalent page in german using a pattern so the same script can be used for each page. Thanks in advance for any suggestions.
January 17, 201313 yr I'm no expert in PHP but I think you need to do a check to identify which language they have installed, assign it to a variable and then place it in a header redirect.
January 18, 201313 yr Author yes, just don't want to have to specify different redirect address on each page. So I want a way of php detecting the page url say it's www.example-site/contact.php and then putting in the relevant subfolder within that path, i.e. www.example-site/spanish/contact.php so I could use the same code on each page. How do I get the language folder put in the path in correct order? Cheers
January 18, 201313 yr Hello How do I write a script in php that will redirect to within a certain folder structure... basically if I have an english site - www.example-site.com and a spanish version of the site within the subfolder www.example-site.com/spanish/ and a german in www.example-site.com/german how do I create a script that will say go to the same page but in the german site. So if they are on a page in english site but an earlier script recognises they have german set as their browser language how can I make it redirect to the equivalent page in german using a pattern so the same script can be used for each page. Thanks in advance for any suggestions. as mentioned do a check to see what language was installed then use a swtich statement switch($lang){ case 'en': //English redirect break; case 'spanish': //Spanish redirect break; }
January 18, 201313 yr Author no I've got that bit, it's just I don't want to have to put the script at the top of each page and put a different redirect in for each page. for eg. on home page i'd have switch($lang){ case 'en': //English redirect header ("Location: http://www.example.com"); break; case 'spanish': //Spanish redirect header ("Location: http://www.example.com/spanish"); break; } whereas on contact page I'd need a different redirect... header ("Location: http://www.example..com/spanish/contact.php"); is there something I can write that basically says... case 'spanish' 1. work out current url, answer www.example.com/photos-page.php 2.Recreate that url with /spanish/ in the correct place (i.e. www.example.com/spanish/photos-page.php) That is what I'm trying to figure out , if that makes sense
February 3, 201313 yr If you have a properly made site you wouldn;t be redirecting at all. Ideally, the language would be a parameter passed to your bootstrap code. So site.co.uk/en/news/index would load the news controller, using the English language file. Having a dupliacted versions of the site in different folders is plain stupid in my eyes and leads to lots of duplication. For instance, say you find a bug in one of your controllers. YOu'll need to duplicate that fix ac ross however many languages you have. All creating lots of hard work for yourself. Seriously, for things like internationalisation you REALLY want to invest some time in a decent framework. Re pasting the code on each page, surely you have a bootstrap file used on every page? This x1000
Create an account or sign in to comment