Re: Cayenne in i18n applications

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Dec 19 2005 - 07:03:41 EST

  • Next message: Cris Daniluk: "Re: Cayenne in i18n applications"

    Gary,

    I have a plane to catch, so I have very little time to respond with
    something meaningful, but just wanted to point to this cayenne-user
    thread on the i18n subject. I liked the approach described by Cris,
    though I am not sure how it applies to your case:

    http://www.objectstyle.org/cayenne/lists/cayenne-user/2005/06/0198.html

    Andrus

    On Dec 19, 2005, at 2:54 PM, Gary Jarrel wrote:

    > Hi All!
    >
    > I need to use Cayenne for a multi-lingual application that I'm
    > currently working on.
    >
    > My main concern was to come up with a way to be able to get data from
    > the DB without explicitely stating that the translated data should
    > come from a different tables.
    >
    > For example I've got two tables news and news_ru. I wanted to have a
    > system whereby the user sets the locale when he/she enters the site,
    > and the respected data is retrieved automatically.
    >
    > So I've come up with a small framework that works. I've used a
    > one-to-one relationship from news to news_ru table, assuming that
    > there will ever be one or none Russian translation for any given
    > record in the news table.
    >
    > I've then overrode the readProperty method of the DataObject in what I
    > called LocalAwareCayenneDataObject. So the News object extends the
    > LocalAwareCayenneDataObject, while the NewsRu extends DataObject. If I
    > retrieve a news entry from the DB, hence I have News object, then I
    > call a getBody method (body field in the database) the system checks
    > whether there is a predefined Locale associated with a thread. In case
    > there is a Ru locale it will actually return a value in Russian from
    > the news_ru table.
    >
    > Basically it uses reflection to find whether there is a method that
    > returns NewsRu and if so it then checks whether there is a body field
    > in the news_ru DbEntity, and if so returns that instead of the English
    > translation which normally lives in the news table.
    >
    > Now this seems to work really well, under my "ideal" test cases :)
    > however in overriding the readProperty method, I'm wondering what
    > implications this may have have on Cayenne functionality, what else
    > should I be testing for?
    >
    > Thanks in advance
    >
    > Gary
    >



    This archive was generated by hypermail 2.0.0 : Mon Dec 19 2005 - 07:03:44 EST