Jump to content

Help / Advice


jaymc

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/152066-help-advice/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/152066-help-advice/#findComment-798603
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.