PHP Language translation for website

Posted on 2006-05-15
Last Modified: 2012-03-15
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,

Question by:Karen Liddy
    LVL 9

    Expert Comment

    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
    LVL 2

    Expert Comment

    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.
    LVL 16

    Expert Comment


    Author Comment

    by:Karen Liddy
    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

    LVL 16

    Accepted Solution

    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

    Author Comment

    by:Karen Liddy
    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now