SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create a Multi-language site?

    Hey all,

    How would I create a multi-language site? I am having a hard time understanding how people approach multi-language sites from reading previous posts (different databases, PHP, mySQL, tables, strings, etc.). Is there one real simple way of creating a multi-language site?

    I just need to translate my site from English to Chinese and the text will be manually translated. The visitor will be able to select a specified flag to switch from one language to another.

    Let me know what you recommend doing. Any help is appreciated. Thanks.

  2. #2
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the case of systems like oscommerce then the multi language issue is dealt with using language files that contain php constants. To do this you would create a php file for each language which would look a little like this:

    english.php:
    PHP Code:
    define("WELCOME""Hello world."); 
    french.php
    PHP Code:
    define("WELCOME""Bonjour Monde"); 
    Then at the top of each file, or in a global include, you would determine which language and include the relevant language file e.g.

    PHP Code:
    include 'languages/'.$_SESSION['lang'].'.php'
    Then when you want to call in that text you simply echo the constant name:

    PHP Code:
    echo WELCOME
    Not sure quite how well this would work with chinese as you may have some encoding issues but that is the general concept, hope it helps

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to confirm whether I am understanding how to properly set-up a multi-language site...

    So basically, there is separate *.php file defining strings of text while a global *.php code is placed on top of each document pointing out which language to choose from. To top it off, I need to place "echo" before the text that I would like to translate.

    Let me know if I am understanding this correctly. Thanks for all the help.

    Quote Originally Posted by seengee View Post
    in the case of systems like oscommerce then the multi language issue is dealt with using language files that contain php constants. To do this you would create a php file for each language which would look a little like this:

    english.php:
    PHP Code:
    define("WELCOME""Hello world."); 
    french.php
    PHP Code:
    define("WELCOME""Bonjour Monde"); 
    Then at the top of each file, or in a global include, you would determine which language and include the relevant language file e.g.

    PHP Code:
    include 'languages/'.$_SESSION['lang'].'.php'
    Then when you want to call in that text you simply echo the constant name:

    PHP Code:
    echo WELCOME
    Not sure quite how well this would work with chinese as you may have some encoding issues but that is the general concept, hope it helps

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice, thanks for the links. I will check it out and hopefully, I can figure this out.


  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Just to confirm whether I am understanding how to properly set-up a multi-language site...
    From what I have read there is no "proper way", hopefully those links I gave you will introduce some of the complexities you need to address. As ever the answer is, "it depends" on what kind of site you have.

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use gettext, which is a pretty standard way to do it. If you are unable to use the gettext extension, use the PHP class. gettext makes it easier for translators to do what they need to do, and it's faster than using arrays if you're using the extension.

    The content can be translated by storing a language key with each article in the database.

  8. #8
    SitePoint Enthusiast whoever's Avatar
    Join Date
    Dec 2005
    Location
    Beijing
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    creating a multi-language site itself is not difficult for me, while marketing really takes time. On June, I worked together with a colleague from Russia and made a multi-language site for a Russia-based presitious hospital. The website development and Chinese translation took us something like 20 days only; while it take us more than 30 days to have its webpages indexed by google China and Baidu-the largest Chinese search engine even though we worked terriblely on the marketing aspect. So my suggestion is: you should try to consider all factors that will impact your future online success before launching a Multi-language site. Once you think you are qualifed, then you can start off!


Tags for this Thread

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
  •