/    Sign up×
Community /Pin to ProfileBookmark

Multi language support

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.

Thanks,

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@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"); }

$text=mysql_fetch_array($query);

echo $text[welcomeMessage];
[/QUOTE]
Copy linkTweet thisAlerts:
@NogDogNov 27.2007 — The are a number of PEAR packages for internationalization you might want to take a look at:

http://pear.php.net/packages.php?catpid=28&catname=Internationalization
Copy linkTweet thisAlerts:
@SenthilnathannsauthorNov 28.2007 — Hi werred

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.
Copy linkTweet thisAlerts:
@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]
Copy linkTweet thisAlerts:
@SenthilnathannsauthorDec 05.2007 — Hi bokeh

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?

Thanks
Copy linkTweet thisAlerts:
@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...

If there any, please, let me know... ?

regards,

Andre
Copy linkTweet thisAlerts:
@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.
×

Success!

Help @Senthilnathanns spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...