Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2005, 03:59 AM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to js_pandey Send a message via Yahoo to js_pandey
Default multi lingual website with php - how can I?

Can anyone help me about how can I develop a multi-lingual website using PHP & mySql? Please help me. its urgent.

Thanks!

Cheers!
I am Jay.
contact: js_pandey at yahoo.com
__________________
Cheers!
I am Jay.
contact: jays_pandey at yahoo.co.in
 
Old May 29th, 2005, 04:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What you want to do is isolate ALL of your text into a separate page. Each message that can be output to the user is defined as a variable. Each language should define all the same variables, but in different languages.

Your PHP script will require() the strings file for your language. Then, whenever anything is output to the client, you'll output the variable name, not the string itself.

Confusing? Yes. Here's what I mean:

<?php // strings.en.php English strings
$greeting = "Hello";
?>


<?php // strings.es.php Spanish strings
$greeting = "Hola";
?>


<?php // strings.gr.php Greek strings
$greeting = "Yia sou";
?>


<?php // index.php Main script

$lang = 'en'; // Default to English;

if (isset($_GET['lang']))
{
    $lang = $_GET['lang']
}

require("strings.{$lang}.php");

echo $greeting. "\n";

echo "View this page in:\n";
echo '<a href="?lang=en">English</a>\n';
echo '<a href="?lang=es">Spanish</a>\n';
echo '<a href="?lang=es">Greek</a>\n';

?>


Keep in mind that this is only a very simple example. Any robust open-source PHP application should have a more real-world implementation of this idea. But the concept is the same -- you localize all your output strings into a language-specific string table, and swap out the tables depending on which language you're dealing with. I think that phpMyAdmin does this.


Take care,

Nik
http://www.bigaction.org/
 
Old May 30th, 2005, 06:01 AM
Authorized User
 
Join Date: Jan 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to js_pandey Send a message via Yahoo to js_pandey
Default

I understood the things.
Thanks you very much for your help and support.

so many thanks!
CHEERS!!!

Cheers!
I am Jay.
contact: js_pandey at yahoo.com
 
Old March 30th, 2011, 07:06 AM
Registered User
 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i also liked the suggestions.





Similar Threads
Thread Thread Starter Forum Replies Last Post
multi Drop down list in PHP Star007 Pro PHP 6 March 17th, 2012 02:18 PM
Multi-language website: almost there electricspace ASP.NET 2.0 Basics 0 July 28th, 2007 06:21 PM
Multi-lingual support aravwind General .NET 4 July 21st, 2004 08:18 AM
PHP MySQL Website Programming - Where is it? matius All Other Wrox Books 1 August 14th, 2003 11:13 AM
PHP MySQL Website Programming P-D-S robmorrish All Other Wrox Books 1 August 5th, 2003 01:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.