SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    best advice for building a multilingual site

    Hi All,

    I'm looking into building a multilingual website, and I'm looking for hints and tips, do's and don'ts, for the best way to organise/structure a site such that it will be as easy as possible to add additional languages in the future. I'm not looking for programming tips (so I might not be in the best forum) - I'm after fundamental, generic stuff.

    My broad approach right now is to break a website down into its main structutural elements that will require alternative content based on language, and then to work out how best to structure that content.

    Examples of main structural elements that are affected by language:
    1. Menu system
    2. Hidden content (eg. meta tags, title tags, etc.)
    3. Help text
    4. Form field names
    5. Error reporting
    6. Auto-generated email messages
    7. etc.

    ... so now I've got to consider where best to source the language-sensitive content, eg.
    1. Database table
    2. Pre-defined (php) global variables
    2. Included text files
    3. other?

    Miscellaneous notes:
    - If possible I will ensure that no text is contained in any graphic, therefore images will never require changing based on language selection.
    - From a visual maintenance point of view, I'm working on the assumption that this general idea:
    /include/faq_english.php
    /include/faq_french.php
    /incude/faq_german.php

    is preferable to:

    /english/include/faq.php
    /french/include/faq.php
    /german/include/faq.php

    Any hints and tips (or pointers to other articles discussing this challenge) would be gratefully received :-)
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  2. #2
    SitePoint Addict Avido's Avatar
    Join Date
    Jul 2003
    Location
    Kortrijk, Belgium, Europe, the world
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use a text file for each language. And every piece of text, label, ... is put into a variable(the same for each language).

  3. #3
    SitePoint Guru quenting's Avatar
    Join Date
    Dec 2002
    Location
    Switzerland
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Avido
    I use a text file for each language. And every piece of text, label, ... is put into a variable(the same for each language).
    same here. Only 1 php file of each type and 1 (or more) text file per language. When db contents are different from one language to another, one table per language.

    Quentin
    The largest message boards on the web !
    unblog.fr, hosting 700000 french blogs

  4. #4
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your feedback.

    From one perspective I would like to have just a single language file. It would contain a list of arrays, where the array name is in English (the default language), and then each element of each array lists the different language versions. Take a look at this v. simple example:

    Lang Name Lang ID
    English 0
    French 1
    Spanish 2

    thus...

    $hello = array("hello","bonjour","hola")

    So if the user selects French as his/her chosen language we'd reference $hello[1].

    The simplicity of this approach is that it's extremely easy to maintain a single file containing multiple languages.

    The downside of this approach - especially as more and more languages are added and/or the site requires more text to be displayed - is that this single file could get very large. Eg. If my site has 10 languages, then a single file containing all languages would have to be included in it's entirety even though 90% of the text content is not required.

    So I guess the only scalable way - if less easily maintainable - is to have 1 file per language.
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  5. #5
    SitePoint Zealot Hulkur's Avatar
    Join Date
    Oct 2001
    Location
    Estonia
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use same array for each language and include only one language file

    Code:
    swich ($lang) {
      case "fr": include_once('fr.lang'); break;
      case "es": include_once('es.lang'); break;
      }
    and xyz.lang
    Code:
    $lang_array=array(
      "hello" => "bonjour",
      ...
      );
    usage:
    Code:
    echo "Hello is ".$lang_array["hello"];
    this way you don't have to remember any additional information (array index for lang etc)

    for new language just copy one of existing files and insert correct translation
    (2B) or (not 2B) = FF

  6. #6
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i put my language data into a database.
    On the long run and especially if more people are maintaining the project, it pays off.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  7. #7
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by frezno
    i put my language data into a database.
    On the long run and especially if more people are maintaining the project, it pays off.
    One table per language? I guess you then have a CMS to maintain the database - custom written or some open source offering? Let's say I was tasked with adding a Spanish version - when I log in to the CMS would I see all the other translations for a word or phrase with an empty box where I fill in my Spanish version of the same, or would I see just the English version (or other single language) with an empty box for the Spanish version?

    Just knocking some ideas around - thanks all for your comments so far, this is really great stuff :-)
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  8. #8
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How you handle the database organization it's upon you taste, it also depends on how big is your application.
    You can put all this in one table or you can break them down e.g. into themes like shop, technical, news, others. You even can use one table per page

    And yes, to maintain you should use an admin panel.

    There you can creating something like VIEWs (MySQL unfortunately doesn't support this) and group items which belong together.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  9. #9
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you already see the potential issues as the site expands with file arrays ,they just get too big & slow at some point.

    Have you considered apache's builtin content negotiation ? you would still need a backend capable of administration of the language content , but why not use that info to create pages for each language (be it on the fly or create/update whenever admin changes) and let apache do the rest , it will serve content in the closest language available (configurable) and you dont have to worry aboiut catching/handling unknown languages as apache will always serve up something.

    not the easiest route to travel in the first place but pretty funky when it finally gets together.

    Thats if you have a lot of static content.... if not it may be overkill ?


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
  •