Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

How to make the PHP website bi-lingual

General discussions related to php

Moderators: macek, egami, gesf

How to make the PHP website bi-lingual

Postby ransome » Tue Jan 14, 2003 6:44 pm

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:
ransome
New php-forum User
New php-forum User
 
Posts: 7
Joined: Tue Jan 14, 2003 6:36 pm

Postby Joan Garnet » Wed Jan 15, 2003 4:44 am

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: Select all
$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: Select all
$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: Select all
echo "<img src='images/'".$HTTP_POST_VARS["language"]."/icon.gif>";

bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Re: How to make the PHP website bi-lingual

Postby WiZARD » Wed Jan 15, 2003 11:49 pm

If you interesting i look in internet very good realization of language system:
1) http://www.phorum.org
2) http://www.phpBB.com
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Re: How to make the PHP website bi-lingual

Postby ransome » Sun Jan 19, 2003 4:12 pm

WiZARD wrote: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
ransome
New php-forum User
New php-forum User
 
Posts: 7
Joined: Tue Jan 14, 2003 6:36 pm


Return to PHP General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.