Re: Transparent i18n?

From: Greg Stark <gsstark(at)mit(dot)edu>
To: David Pratt <fairwinds(at)eastlink(dot)ca>
Cc: Steve - DND <postgres(at)digitalnothing(dot)com>, postgres-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Transparent i18n?
Date: 2005-07-02 06:20:08
Message-ID: 87r7ehwwyv.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


David Pratt <fairwinds(at)eastlink(dot)ca> writes:

> It was suggested that I look at an array.

I think that was me. I tried not to say there's only one way to do it. Only
that I chose to go this way and I think it has worked a lot better for me.
Having the text right there in the column saves a *lot* of work dealing with
the tables. Especially since many tables would have multiple localized
strings.

> I think my table will be pretty simple;
> CREATE TABLE multi_language (
> id SERIAL,
> lang_code_and_text TEXT[][]
> );
>
> So records would look like:
>
> 1, {{'en','the brown cow'},{'fr','la vache brun'}}
> 2, {{'en','the blue turkey'},{'fr','la dandon bleu'}}

That's a lot more complicated than my model.

Postgres doesn't have any functions for handling arrays like these as
associative arrays like you might want. And as you've discovered it's not so
easy to ship the whole array to your client where it might be easier to work
with.

I just have things like (hypothetically):

CREATE TABLE states (
abbrev text,
state_name text[],
state_capitol text[]
)

And then in my application code data layer I mark all "internationalized
columns" and the object that handles creating the actual select automatically
includes a "[$lang_id]" after every column in that list.

The list of languages supported and the mapping of languages to array
positions is fixed. I can grow it later but I can't reorganize them. This is
fine for me since pretty much everything has exactly two languages.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2005-07-02 09:08:31 Re: Transparent i18n?
Previous Message Michael Fuhr 2005-07-02 03:04:57 Re: Get Query in Statement Level Trigger?