How can you make multi-language website in php

Discussion in 'PHP' started by bhupendradwi, Aug 31, 2011.

  1. #1
    Please help me someone How can you make multi-language website in php?
     
    bhupendradwi, Aug 31, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Put a link to the other language pages on each page and let the user choose the language.

    How do you do it automatically, so that each user sees the site in his preferred language? You could use cookies, but the user would still have to make the choice at least once.

    How do you do it without the user having to choose? You don't. You could use the country the user's IP address is from, but that means that an American tourist in Italy would always get your Italian page - and if he doesn't understand Italian, he'll never go back to your site.
     
    Rukbat, Aug 31, 2011 IP
  3. programmer_best1

    programmer_best1 Well-Known Member

    Messages:
    282
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    133
    #3
    set Cookie for the active language id through php function and read it back.
     
    programmer_best1, Sep 1, 2011 IP
  4. HalvinCarris

    HalvinCarris Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It is possible to create multiple language files, containing arrays with the text you want translated. Something like this:

    $lang['home'] = 'Welcome on our website'];

    And then use $_GET parameters to set the desired language.
     
    HalvinCarris, Sep 3, 2011 IP