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

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.


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 With The Languages? wrote:
Quoted text here. Click to load it


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.

Erwin Moller

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

adam.timberlake wrote:

Quoted text here. Click to load it

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  

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:

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

                      Gnocchi all'Amatriciana al Forno

Site Timeline