|
Posted by Erwin Moller on 09/28/16 12:00
adam.timberlake@gmail.com wrote:
> hello everybody
>
> i have been reading the article below in case you are wondering, but i
> have myself a question about how good the structure really is, and if
> there are any better ways to do this.
>
> article: http://www.talkphp.com/vbarticles.php?do=article&articleid=46
>
> i do like how that site has done it but as i dont know alot about php,
> i cant tell whether its a good solution or not, so could somebody
> please tell me if it is ?? if it is accepable then i shall it :)
>
> thank you and good night!
Hi,
Basically, multilangual pages boils down to seperating blocks of text.
The example given on that page uses xml to store it.
I would prefer a database, but the idea is the same: get a block of text
based on some language.
I prefer database storage because I really dislike xml and its
parsingspeed. Why-oh-why do people use xml for everything?
If you want to go database, you can create something like this:
[serial is postgresql's for 'autonumber' like field]
// define languages in here
create table tbllanguage(
languageid integer serial PRIMARY KEY,
language text
)
// define the names of used textblocks in here
create table tbltextblock(
textblockid integer serial PRIMARY KEY,
textblock text
)
// query this table with languageid and textblockid to get the text
create table textlang(
textlangid integer serial PRIMARY KEY,
languageid REFERENCES tbllanguage(languageid),
textblockid REFERENCES tbltextblock(textblockid),
thetext text
)
A few thing to consider:
1) It may be wise to query all needed textlang.thetext at once for a
page. So you need to set up some system that knows which textblocks to
fetch. (If not, you need eg. 20 seperate queries, which is slow)
2) If you need to support languages with characters outside ascii,
you'll want to use unicode for textlang.thetext.
3) make sure you use the right headers for your document, so you set the
right characterset.
Hope that helps.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|