Cayenne in i18n applications

From: Gary Jarrel (garyjarre..mail.com)
Date: Mon Dec 19 2005 - 06:54:22 EST

  • Next message: Andrus Adamchik: "Re: Cayenne in i18n applications"

    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 - 06:54:23 EST