multilingual system
Posted: Thu Dec 23, 2010 6:39 pm
I want to setup my database in a way so that it supports multi-languages for certain things. For example, a menu structure + the content. But the problem is, is that i'm not sure how to set this up.
I thought of two possibilities.
1. I could setup my table like this:
This way i could easily select the desired menu item + its content with a simple "WHERE lang = '$language'" in a query.
The downside is that i also want to show this in a CMS page. But i want it so that both languages can be editted at the same time. So suppose i show a html table in the CMS page, with 2 columns. In the left column i show the EN menutitle and content - and in the right column i show the NL menutitle and content. Below that is a Submit button that should save the menutitles and contents of both languages to the database. But how on earth am i going to know which POST values belong to EN and which VALUES belong to NL...???
On the other hand, i could also create a table like this:
tablename: menu
id, menutitle_en, menutitle_nl, content_en, content_nl
I know this isn't a normalized database structure, but it does make the job easier when i want to save the content to the database. Take the CMS page example that i described earlier, with the 2 column table.
In the left column i simple create textfields that match the name of the database column names. So that way i can always tell what POST data to save in what column. But this is most probably not the cleanest way to go...
So my question basically is, what is the correct way of doing this? Any of the above? Or something, completely different...?
I thought of two possibilities.
1. I could setup my table like this:
Code: Select all
tablename: menu
id, menutitle, content, lang
1 mainmenu hello en
2 hoofdmenu hallo nl
The downside is that i also want to show this in a CMS page. But i want it so that both languages can be editted at the same time. So suppose i show a html table in the CMS page, with 2 columns. In the left column i show the EN menutitle and content - and in the right column i show the NL menutitle and content. Below that is a Submit button that should save the menutitles and contents of both languages to the database. But how on earth am i going to know which POST values belong to EN and which VALUES belong to NL...???
On the other hand, i could also create a table like this:
tablename: menu
id, menutitle_en, menutitle_nl, content_en, content_nl
I know this isn't a normalized database structure, but it does make the job easier when i want to save the content to the database. Take the CMS page example that i described earlier, with the 2 column table.
In the left column i simple create textfields that match the name of the database column names. So that way i can always tell what POST data to save in what column. But this is most probably not the cleanest way to go...
So my question basically is, what is the correct way of doing this? Any of the above? Or something, completely different...?