Actually translation table makes a lot of sense. It is the least
invasive solution, and can be generalized in Cayenne. Using Locale-
specific views may not be easy to integrate, but creating some kind
of I18nManager with API shown below should be fairly easy based on
the translation table idea:
interface I18nManager {
// This is straightforward
String getString(DataObject object, String property, Locale locale);
// this may require some magic to make sure it is committed
together with the DataObject
void setString(dataObject object, String property, String value,
Locale locale);
}
Internally it can use SQLTemplate to serve translated strings either
from a single global translation table or multiple tables (one per
locale), or any other strategy that makes sense (as SQLTemplate
allows table name to be a dynamic parameter). With this and a custom
code generation template we can create DataObjects with
internationalized properties. I really like this idea.
Andrus
On Jun 23, 2005, at 4:06 PM, Adrian Wiesmann wrote:
>> I would think it would be easier to have a separate table for each
>> Locale. ie, My_table, my_table_de, my_table_fr.
>>
>
> I know I could get shot to mention this in some places (and it asks
> for a
> bit of a hack with Cayenne). But why not have one translation table
> and
> every other table using the translation like the example below.
>
> It needs a good setup and a rock solid access layer, but let me
> show this
> with an example:
>
> TableGoods
> ----------
> uuid=abcd;price=12£
>
> Translation
> -----------
> key=name;text=Tshirts;foreignkey=abcd
> key=description;text=Nice TShirts showing my face;foreignkey=abcd
>
> When trying to access the data you never call TableGoods directly
> but a
> view or some other mechanism which fills a virtual table:
>
> TranslatedGoods
> uuid=abcd;price=12£;name=Tshirts;description=Nice TShirts showing
> my face
>
> like that you never have to change the database when there is a new
> language and you have no problems with synching tables.
>
> Just some input, now I will hide :)
>
> Regards,
> Adrian
>
>
This archive was generated by hypermail 2.0.0 : Thu Jun 23 2005 - 16:37:11 EDT