Re: [Phplib-users] Templates and i18n...
Brought to you by:
nhruby,
richardarcher
|
From: Richard A. <rh...@ju...> - 2002-12-03 03:01:08
|
At 17:11 -0800 2/12/02, Aric Caley wrote:
>Well, because right now, the template might look like this:
>
><h1>{TITLELABEL}</h2>
>
>And the code would have this:
>
>$template->set_var(array("TITLELABEL" => getText("This is the page
>title")));
OK, I can see where you are going with this. I would approach this
slightly differently.
I would build a database with the translations in it. Columns like:
lang char(2), # ISO country code
varname char(16), # contains the template varname
trans text, # the translated text
with indexes on lang and varname
The template file would contain lots of tags like:
<h1>{TITLELABEL}</h1>
You can extract all the template varnames from the template file with
a preg_match_all(). Then loop through the results generating a massive
SQL query which pulls all the text translations required for that page
out of the database with one query. Then loop through the SQL result
set and call $t->set_var($db->f('varname'), $db->f('trans')) for each
record.
Your PHP script wouldn't even need to know the template varnames :)
...R.
|