www.webdeveloper.com
Results 1 to 4 of 4

Thread: How to develop multilingual website?

  1. #1
    Join Date
    Feb 2007
    Posts
    84

    How to develop multilingual website?

    Hello forums!!

    I would like to have the experts to share about developing multilingual websites.

    AFAIK, Multilingual Websites generally consists of two parts:
    1> Static (Form labels, Header titles, Messages etc., Generally file based)
    2> Dynamic (Db Contents like Categories, news posts etc, Obviously db based)

    Managing Static contents is easy which can be easily done as:
    Code:
    en
    - form_label.php
    - messages.php
    :
    etc
    nl
    - form_lable.php
    - messages.php
    :
    :
    language files generally consists of associative arrays or defined as constants for the static content translation.

    But the complexity part comes with the Dynamic contents translation.
    I would like to know how you develop the multilingual website (esp for dynamic contents).

    Thanks for the ideas/suggestions in advance.

  2. #2
    Join Date
    Feb 2007
    Posts
    84
    For db design for multilingual website, i have come up with following solutions
    and don't know which one is perfect also want to know if there is any other good options

    Obviously firstly we need language table as:
    ----------------
    |languages
    ----------------
    |id
    |code
    |flag
    |is_active
    ----------------
    Possible solutions
    1> using one table(suppose we have 'news' table for example)
    ------------
    |news
    -------------
    |id
    |language_id
    |title
    |body
    |created_by
    |created_date
    |is_active
    :
    :
    2> Using two tables
    ------------
    |news
    -------------
    |id
    |created_by
    |created_date
    |is_active
    :
    :
    ---------------
    |news_contents
    ---------------
    |id
    |news_id
    |language_id
    |title
    |body
    ----------------
    3> Using one master table for all tables which needs translation
    --------------
    |news
    --------------
    |id
    |title
    |body
    |created_by
    |created_date
    |is_active
    ---------------
    ------------
    |categories
    -------------
    |id
    |title
    |description
    |is_active
    --------------
    master table:
    ---------------
    |translation
    ---------------
    |id
    |language_id
    |table_name
    |table_field
    |translated_value
    ----------------
    I have found all these structure so far, dont know which one is better as i havent used such in my multilingual website.
    I would like to know the pros n cons for these structures, best db structure.

    Note: Any no of languages can be added ranging from 1 -> N

    Thanks for the help again in advance.

  3. #3
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    You are thinking in the right direction. Plan out what you need specifically for your site design and don't go overboard. Generally you would have basic content sections like info, contact, events, news, etc.; these would reside in your content db. What you are referring to as "static" would be meta, nav, disclaimers, lang labels, etc. and they can reside in a separate db table or in lang include files.
    Keep yourself organized from the beginning to avoid headaches in the future.
    Enjoy!

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    I tend to use gettext-compatible .po files and then define a function to replace the standard echo. Normally something short like _(). This function takes a string argument containing the text to be translated in the default language (English in my case). If a .po file exists for the current user's selected language, the phrase will be used to look up the translation from the file, and the translation will be echoed. If the language or translation doesn't exist, or a non-default language has not been selected, the text is echoed directly.

    This is much quicker than using databases since the file is essentially just key/value pairs, and it is very easy to manage the translations. The bonus is the files are a standard format and can be transported between apps/languages with no conversion work necessary.

    There is also a gettext PEAR package, although I don't use it myself.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles