How to make the PHP website bi-lingual

A

Anonymous

Guest
Dear all,

In order to make the website in bi-lingual, how can I implement with a [LangA/LangB] button with PHP code coded to let the browser to swtich to either language whenever they wnat, and
How should I do to implement the labels, GIFs with two sets of Language written ??



With regards,

Ransome
:cry:
 
I would create a session variable telling which language has been selected and then passing it throughout the site.
Would be interesting to put a cookie, so the language will be automatically selected next time.
Then put all texts of the site in a single php file with the same name of the language: (then you'll have to #include it in each page)
english.php
Code:
$lang['hello'] = 'Hello %';//% is the output of a prinf statement, which in this case would be the name of the user for example
$lang['wellcome'] = 'Wellcome to my website!';
$lang['bye'] = '<b>Thank you</b> for visiting our site!';
spanish.php
Code:
$lang['hello'] = 'Hola %';//% is the output of a prinf statement, which in this case would be the name of the user for example
$lang['wellcome'] = 'Bienvenido a mi página!';
$lang['bye'] = '<b>Gracias</b> por visitar nuestra web!';
This would be for the text of your pages.
The contents I would keep them in the database.

* articles table: (an example)
id - article_name_spanish - article_name_english - art_contents_spanish - art_contents_english

The other way would be separating each language in a table for each section, but it would cause a lot of tables..
It's your choice...

The gifs,
just create an image folder images and subfolders spanish, english, and so on..
The gifs names will be the same in each folder.
To call images, then use this:
Code:
echo "<img src='images/'".$HTTP_POST_VARS["language"]."/icon.gif>";
bye!
 
If you interesting i look in internet very good realization of language system:
1) http://www.phorum.org
2) http://www.phpBB.com
 
WiZARD said:
If you interesting i look in internet very good realization of language system:
1) http://www.phorum.org
2) http://www.phpBB.com

Dear WiZARD,

How can code the "Language selecting button"? and how to refresh the current page to change the language of the project ?


With regards,


Ransome
 
Back
Top