SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi language site

    Hi,

    I am beginning a site from scratch this week. Initially I will be building it in English, however I was to build it in such a way that I can add additional languages at a later date without creating a whole new version of the site for each language.

    How do you usually go about this? I could create an additional php file called english.php with variables such as $paragraph1 = 'Text here' and then include this in my site. I could then change the text in this file to different lanuages and so include spanish.php or whatever, however this seems like a mighty big job as the site will be pretty big and have a lot of information on each page. Some of the text will also be pulled from a database.

    Any suggestions would be great.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    To get the best out of multi-language sites you need to do it by hand you need to hire a professional to translate do not do the quick and easy computer translations they won't cut it.

    Thats just my personal opinion.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    To get the best out of multi-language sites you need to do it by hand you need to hire a professional to translate do not do the quick and easy computer translations they won't cut it.

    Thats just my personal opinion.
    Hi,

    I have people to do the translating itself, I was more curious from a technical point of view how you would go about setting up the system.

    Thanks for your points though

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Hmmm well I would use a combination database for the content but for the elements for the site like navigation, buttons, etc. I would use a language file like xml or what have you; Using to store the textual information and when it comes to display it I would go through a function the pulls the right text from the language file thats been picked.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Regina, SK, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I would do is have language files like english.php, french.php and spanish.php.

    Have an include on each page that has...


    Code PHP:
    if($_GET['lang'] == 'spanish'){
    include("spanish.php");
    }
    elseif($_GET['lang'] == 'french'){
    include("french.php");
    }
    etc...

    and the page be yourpage.php?lang=spanish

    Then in spanish.php have variables like...
    $welcome = 'Welcomo';
    $hello = 'Ola';

    Have all the variables the same in all language files. Then whenever you want to edit content all you need to do is edit the language file. Or add a new variable to the language file.

    If you were storing the information in the database I would have a query inside the $_GET statements.
    Code PHP:
    if($_GET['lang'] == 'spanish'){
    $query = mysql_query("SELECT * from table_spanish");
    }
    elseif($_GET['lang'] == 'french'){
    $query = mysql_query("SELECT * from table_french");
    }
    $data = mysql_fetch_assoc($query);

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Location
    Ukraine
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I prefer to store all translations to the database. May be someone will decide that this is not the best solution, but I cannot find better

    You can look my site for more details of what I am talking about. Just login to the control panel of some demo.
    The idea is partially stolen from osCommerce, but I do not like the way how osCommerce operates with small translations. It requires certain amount of work even to see basic English text on the pages. I do not like this, so I am holding everything in the database and using small tricks to minimize database load.

  7. #7
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dzysyak View Post
    I prefer to store all translations to the database. May be someone will decide that this is not the best solution, but I cannot find better

    You can look my site for more details of what I am talking about. Just login to the control panel of some demo.
    The idea is partially stolen from osCommerce, but I do not like the way how osCommerce operates with small translations. It requires certain amount of work even to see basic English text on the pages. I do not like this, so I am holding everything in the database and using small tricks to minimize database load.
    Thats very possible to put it all in a database but the reason I opted for a filed based was purply for ease of extensibility. Just uploading a file then changing a setting seems much more easier to me then adding or changing a DB table. But your idea will work and nothing wrong with it its all personal preference really
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  8. #8
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dzysyak View Post
    I prefer to store all translations to the database. May be someone will decide that this is not the best solution, but I cannot find better

    You can look my site for more details of what I am talking about. Just login to the control panel of some demo.
    The idea is partially stolen from osCommerce, but I do not like the way how osCommerce operates with small translations. It requires certain amount of work even to see basic English text on the pages. I do not like this, so I am holding everything in the database and using small tricks to minimize database load.
    I guess this was kind of what I was asking. It putting everything into a database not going to slow the site down to a crawl under heavy use?

  9. #9
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by grandad View Post
    I guess this was kind of what I was asking. It putting everything into a database not going to slow the site down to a crawl under heavy use?
    its

    No
    Go visit my site :-D you know you want to ;-)
    www.mech7.net


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •