I am in need of implementing multi language support in my site. I need some suggestions and advice on this. I googled on these topics, but can’t able to come to a conclusion. Please help me on this regard.
@werredNov 27.2007 — #There are many ways to do this though the simplest is to create for each language a separate database table so you could store the text.
After you have all the necessary static text in your database you may simply:
if($language=="english") { $query=mysql_query("SELECT * FROM english); }
if($language=="german") { $query=mysql_query("SELECT * FROM german"); }
I'm using MYSQL database. What changes do i need to make in MYSQL so as to support for multiple languages. And how the strings are stored in MYSQL? do i need to change anything in php for the reflection.
@bokehNov 28.2007 — #if($language=="english") { $query=mysql_query("SELECT * FROM english); }
if($language=="german") { $query=mysql_query("SELECT * FROM german"); } [/QUOTE]Wouldn't it be easier to do this:[code=php]$query=mysql_query("SELECT * FROM $language");[/code]
How to insert or update the multi language string content to DB? Is any changes do I need in MYSQL for supporting multilanguage string storage? Also how the strings are stored in MYSQL?
@andre4s_yDec 06.2007 — #There is another way to implement multiple language without using DB. ?
first, change all your text by the constant variable.
old : [code=php]echo "Good Morning";[/code] new : [code=php]echo _GOODMORNING;[/code]
and then define the constant variable with different language. [code=php] <?php //language-id.php define("_GOODMORNING","Selamat Pagi"); [/code] or [code=php] <?php //language-en.php define("_GOODMORNING","Good Morning"); [/code] or [code=php] <?php //language-de.php define("_GOODMORNING","Guten Morgen"); [/code] After that, you can include the language-xx.php file.
If you need English, just include the language-en.php.
I found this kind of implementation in PHP Nuke, years ago.. ?
So, i do not know if there is an unsecure thing there...
@kattenDec 07.2007 — #@up: if your homepage was huge, that would require a bloody large amount of constants maybe not the best for the server processing.
@thread: Simple way to support multilanguage
This example requires a base file (english.php) [code=php] <?php return array( 'welcomeMessage' => 'Hello and welcome to my homepage', 'goodByMesssage' => 'Cya later, i hope you come back soon' ); ?> [/code]
Example one (If your using some kind of homemade template engine) [code=php] public function loadLanguage($language = 'english'); { $this->_langauge = include('./langauges/'.$language); }
public function getlanguageVar($varible) { $this->_language[$varible]; } [/code]
Example 2 basic [code=php] <?php $language = include('./languages/english.php');
echo $language['welcomeMessage']; ?> [/code]
I guess you can figure out the rest of my code, else just send me a pm i will answere as fast as i can.