|
Posted by Markus Ernst on 01/12/06 20:32
BLob schrieb:
> Hi,
>
> I am building a multi languages website. To simplify let's say that I need
> to deal with news, projects, partners, all of them having some information
> depending on the language (title, introduction, ...) and some not depending
> on the language (date_online, date_offline, published, ...). The main point
> is that I don't want to have to touch the structure of the database or to
> modify my scripts if one or more languages were to be added. I came up with
> something like this :
>
> My architecture:
> ----------------------------------------------------------------------------
> ------
> 'news' table: with all information not depending on the language
> news_id (primary key)
> date_online
> date_offline
> published
> ...
> 'news_translations' table: with all information depending on the language
> news_id (primary key)
> lang (primary key)
> title
> introduction
> ...
> The (news_id, lang) is linking the second table to the first one.
>
> Same kind of structure for all other content that needs to be translated
> (projects, partners, etc.).
>
>
> Is there a better approach: something using only one table with all the
> information that has to be translated, coming from any table (news,
> projects, partners, etc.) ? or something else ?
I use a table 'strings' with the fields:
- stringnumber
- language
- string
and in the 'news' table I have all the fields necessary, but all
multilanguage fields contain the stringnumber instead of the text itself.
I could not say if this approach was better than yours, it is just
different. The advantage of it is that you have access to any string
regardless of the information about what object it belongs to. This
makes it easy to make fallbacks for the case some info is not present in
the desired language, somehow like
function get_string($str_nr, $lang, $main_lang) {
$string = [get string for $lang here];
if ($string == "" || $string == NULL) {
if ($lang != $main_lang)
return get_string($str_nr, $main_lang, $min_lang);
else
return false
}
else return $string;
}
HTH
Markus
[Back to original message]
|