SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Internationalization and multiple languages on one site

    I would like to create a site where the user can select the language on the fly and all navigation elements and forms would be in that language. i.e I would like users to be able to browse my site in different languages.

    What is the best way to acheive this? Create a different page for each language? Is there some way to use the same page, but just have the navigation elements show up in the language of choice? Are there any tools out there that can help with this.

    Forgive me if I am not making myself very clear, as I am not a developer. Oh, and the reason I am posting this here because I am already running the PHP based script in English. Now, I want to expand the languages.

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Generally speaking, it's best to build multi-language support in from day one, but it sounds like it's too late for you to do that.

    Normally you would refer to all on-screen text (error messages, menu items, form prompts etc.) using variables, and then including the variables from an external file. The language file included would depend on the language selected.

    e.g.

    file: lang.en
    Code:
    $error_01 = "Enter all information"
    file: lang.fr
    Code:
    $error_01 = "Écrivez toute l'information"
    file: lang.es
    Code:
    $error_01 = "Incorpore toda la información"
    file: index.htm
    Code:
     ...
     
     include "lang.fr";
     
     ...
    
       
    if(a !=  b){echo $error_01;}
       
       ...

    Andy
    From the English nation to a US location.

  3. #3
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could include the navigation from different files depending on the language, you could use a template system and reference the templates accordingly or or or. It all depends on your current approach to the site, meaning whether you already use templates or the like.

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by awestmoreland
    Generally speaking, it's best to build multi-language support in from day one, but it sounds like it's too late for you to do that.

    Normally you would refer to all on-screen text (error messages, menu items, form prompts etc.) using variables, and then including the variables from an external file. The language file included would depend on the language selected.

    Andy
    Thanks, I think I get the idea. Yes, I already have the site up and running, so there would be some retrofit involved. I think there are about 10 pages that would require changes. So, it looks like it can be done. It will just take a bit more work than it would have done if it had been incorporated from the start.

  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMHO, more easy and correct way for translating allready life site content is:
    1. Setup gettext (or PEAR::i18n library) for current language
    2. Change all existing output for gettext (i18n) format

    After this step you have working site with one language but ready to translation.

    3. Grab all gettext output in new-language file
    4. Translate all terms in this file

    After this step you will have working site with two languages.

    Icheb give you right solution about navigation and templates.
    If you not using templates system, but you have "ideal" CSS-design - you can change stylesheets only.

    After all you will have only one problem: how to internationalize DB information?
    There are several ways. Most easy and fast - create translated tables-clones for each exitsting table. I mean if now you allready have table articles then after adding spanish language you will have to tables: articles_en and articles_es
    All you need to change in code - just append current language code to table names in your SQL queries.

  6. #6
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tip Eugene. This is something that I may well be attempting in the near future and thought I already had the best method. I'll definitely look into your suggestion when the time comes.


    Andy
    From the English nation to a US location.

  7. #7
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi:

    there is a free CMS (php & mysql) at phpcomasy.org that maybe is what you are looking for: you can include several languages in the frontend and users can select the language of their choice and read the site in that language.

    http://www.phpcomasy.org/web/index.p...guage=en&id=19

    Regards

    Osckar


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
  •