...

View Full Version : How to develop multilingual website?



PHPycho
09-20-2009, 05:49 PM
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:

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.

mlseim
09-20-2009, 06:44 PM
I've looked into this before.
I saved a few bookmarks ...

This one using Smarty, a method of XML files - maybe some good ideas here:
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=84

Then, I realized there are a variety of methods, but I like XML files myself.
I never did the scripting for it though. Here's a lot more information, but I
assume you've already looked here?
http://www.google.com/search?hl=en&q=php+multi-languages&btnG=Search&aq=f&oq=&aqi=

PHPycho
09-20-2009, 07:24 PM
Thats only for static content translation. I want some suggestion for dynmic contents ie db based contents.
Thanks

PHPycho
09-20-2009, 08:22 PM
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.

bazz
09-20-2009, 09:02 PM
-------------
create table languages
( language varchar(99) not null primary key
, code char(3) not null
, flag_image varchar(64) not null
) engine......

English
French
German
Spanish
Italian
etc
-------------



------------
|news
-------------
|id
|language (optional fk to language table)
|title
|body
|created_by
|created_date
|is_active
:
:



then your query works just like when you only provide content in one language but that you conditionalise it with ~ where langauge = 'french'

If there is no content to match the query it will not return a result so I am not sure about the need for an 'is active' column.

I think the biggest issue is, who's going to privide all the translation :) if you have a lot of content pages in your first language, that might lead to an awful lot of translation costs.

On the other hand, if you want only to provide headings in the other langauges (I do dislike the term, foreign), that is likely to be a one to many relationship and 3nf normalisation would resolve that in terms of db structure.

hth

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum