Is This A Good Structure For What I Am Trying To Achieve With The

Is This A Good Structure For What I Am Trying To Achieve With The

am 16.01.2008 14:39:23 von adam.timberlake

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=4 6

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!

Re: Is This A Good Structure For What I Am Trying To Achieve WithThe Languages?

am 16.01.2008 15:08:36 von Erwin Moller

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=4 6
>
> 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

Re: Is This A Good Structure For What I Am Trying To Achieve WithThe

am 17.01.2008 13:08:58 von Toby A Inkster

adam.timberlake wrote:

> http://www.talkphp.com/vbarticles.php?do=article&articleid=4 6

From the article:

| This article will inform you on how many people go about creating
| multilingual websites [...] a parent folder is created and then within
| the parent folder are language directories - UK for the UK, for
| instance, and DE for Germany

Firstly, I've never heard of languages called "UK" and "Germany". There
are countries with those names of course, but not languages. The people of
those languages tend to speak English and German.

If you want two-letter abbreviations for languages, use ISO 639-2 Alpha-2
codes -- no need to go reinventing the wheel. In Alpha-2 codes, English is
"en", German is "de", French "fr" and so forth. A full list can be found
here:

http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

There are also Alpha-3 codes, which cover a superset of the languages of
Alpha-2. It is important to re-use existing standards rather than invent
your own if you want to allow your code to be integrated with other
technology in the future.

As for the rest of the article, it just seems to be writing an inferior
replacement for GNU gettext, which is already integrated into PHP and
works fine for most people. Why replace something that already works well?
I'm guessing because the authors of the article know it existed. Well it
does exist. The documentation is here: http://www.php.net/gettext

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 17 days, 23:08.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatrici ana/