[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Web generation + localization.

From: Peter Bex
Subject: Re: [Chicken-users] Web generation + localization.
Date: Thu, 6 Mar 2008 20:04:11 +0100
User-agent: Mutt/

On Thu, Mar 06, 2008 at 06:09:07PM +0100, Tobia Conforto wrote:
> Peter Bex wrote:
> > Then, you have one translation step that extracts all the (trans ..)  
> > things, resulting in the list ("this is a test", "My first test",  
> > "we have some testing stuff here") which then can be used in one  
> > query that returns the translations.
> How would you look all those strings up in a single query?
> I guess it depends on the database / other storage engine you're going  
> to use, but I'm curious.

How about:

SELECT match.str, translations.translation
FROM translations
FULL OUTER JOIN (VALUES (1, 'hello world'), (2, 'chicken rocks'), (3, 'blah'))
AS match(id, str)
ON translations.source = match.str
WHERE translations.lang = 'nl'

Returns this:
      str      | translation  
 hello world   | hallo wereld
 chicken rocks | chicken regeert
 blah          | NULL

There are probably other ways to do this, but this is what I can come up
with quickly.  The match id is necessary to keep the list in the order you
have the initial to-be-translated strings in.  You can also leave off the
'source' column as that's not strictly necessary since we generate the
result set in the same ordering as our original strings.

The VALUES line would be generated and the translations language can be
selected dynamically as well.  This seems to be a PostgreSQL-only feature,
though.  Another solution would be to generate a temporary table or some
view and select the values from that, or just not to order the result set
and compare the strings you get from SQL in Chicken to the
to-be-translated strings.  Of course, if you define a stored procedure in
your DB you can do anything you want too.

"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: pgp4MXHnn5j8v.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]