• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

PHP Language translation for website

Hi there,
I have a property listing site, i want to be able to change the languages of the site via a button without having to rewrite the whole site again.
Can anyone tell me how this would be done or of any good tutorials for it.  I searched google, phpfreaks, etc, but couldnĀ“t find much

Kind regards,

Karen Liddy
Karen Liddy
1 Solution
you need server side language transition or client side language transition?

client side script transition would need to involve javascripts
you would need to have session, query string or parameter to trigger the changes of the languages.


$_GET["lang"] = "en";

case "en":
$type = "English words";
case "cn":
$type = "Chinese Words";

you may check out how "XAMPP" work out from http://www.apachefriends.org/en/xampp.html
Sometimes the best thing to do is use one that already exists and is well tested.

For example google language tool or babelfish - you can create a link on your pages which passed the UR and desired language to one of these third party sites. These sites then transform the language and display it for the user.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Karen LiddyOffice ManagerAuthor Commented:
Thanks for those replies.

I have seen in places (for e.g. ZenCart) when the page references and external txt file that has the translations already done.  And the page inserts the translated words or paragraphs depending on the values called on the page.

How could this be done using PHP?

Thanks for the links, but non of them had quite what i was looking for.  I want people to be able to add additional languages when and if needed simply by adding the txt file with the translated words, and adding the command on the index page.

The site i'm working on is a property listing site that real estate agents will buy and then go adding modules on to it, including one for language, but i want them to be able to either purchase additional languages or translate them themselves.  So it needs to be really easy, hence the external translated file.

Thanks for help

well, you can make language as a querystring, and based on that language, you select appropriate articles out of the database

$lang= $_GET['lang'];
select * from articles where lang=$lang
Karen LiddyOffice ManagerAuthor Commented:
thank you.  i think that will be the easiest way to do it, and then just have form to insert the paragraphs into the database when they want to add another language.

one last question.  on the index page where iĀ“ll be putting the flag to switch language, i would use this command?
lang=en (english flag)
lang=es (spanish flag)
lang=ge (german flag)

or something along those lines.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now