jaymc Posted April 1, 2009 Share Posted April 1, 2009 I have bespoke website which I have coded using PHP and a MYSQL backend for members My question is, the entire website is written in english language which is hard coded into the php pages e.g. $content = "Hello this is $page_one this text is hard coded"; echo $header echo $content echo $footer I now have a project where I must create different language versions of the website. Some my still be enlgish but written to appeal to english speaking Indians, others may be a spanish / french version What are your thoughts on the best way to go about this. I want to keep the engine (database/code) all together, so no cloning the website and changing the hard code It would be good to load different language via php. I have read a bit about compiling every bit of text into language packs which contain arrays you just include in the php in place of where the hard code once was What are your views on tackling something like this Quote Link to comment Share on other sites More sharing options...
manny Posted April 1, 2009 Share Posted April 1, 2009 I have bespoke website which I have coded using PHP and a MYSQL backend for members My question is, the entire website is written in english language which is hard coded into the php pages e.g. $content = "Hello this is $page_one this text is hard coded"; echo $header echo $content echo $footer I now have a project where I must create different language versions of the website. Some my still be enlgish but written to appeal to english speaking Indians, others may be a spanish / french version What are your thoughts on the best way to go about this. I want to keep the engine (database/code) all together, so no cloning the website and changing the hard code It would be good to load different language via php. I have read a bit about compiling every bit of text into language packs which contain arrays you just include in the php in place of where the hard code once was What are your views on tackling something like this ok lets start by planning the structure of the site... 1:if you want to make a good portable website you will start by building a file system where the actual processing and the views are separated. now you can go about it a few ways you could setup constants in two files for startus for the menus and main sie text such as how to register, or why sign up for our service, etc... now the same like you did up in the page the same way you should go about it... set all constants / $variables in the processing page, then use them in the view page. 2: the actual process... say you have to say hello in english and spanish... so, you set up two files one called english.php the other called spanish.php. in the english / spanish files you define the values english.php <?php define('HELLO','Hello'); ?> spanish.php <?php define('HELLO','Holla'); ?> index.php the view page <? echo HOLLA; ?> the processing page includes/config.php <? //USER Lang Preference $language = $database_result['lang']; require_once('/lang/'.$language.'.php'); ?> so you see that one way of doing it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.