ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: I18N best practices with iBatis
Date Sat, 30 Jun 2007 01:37:11 GMT
So you have a field for each locale?

I'd think it would be easier to if that were a compound key instead:

SELECT a.activity_id, i.name as name
FROM  activities a
JOIN  i18n i ON (a.name_i18n_id = i.i18n_id and i.i18n_locale = #locale#)

But.. I guess you'd still have to pass it to each query...

How about this - if you don't have a ton of locales to support, you
could do this:

SELECT a.activity_id, i.${locale} as name
FROM  activities a
JOIN  i18n i ON (a.name_i18n_id = i.i18n_id)

Then pass in the locale when you create the sqlmap client - each
locale would have it's own sql map client that you could put in a Map,
then put on the thread (use a ThreadLocale) and get from there when
needed. That could be a pretty clean solution if done well.


On 6/29/07, Collin Peters <cadiolis@gmail.com> wrote:
> I have some I18N questions and am wondering what others do out there.
> We have an I18N system setup where there is a database table storing
> all strings and their translations.  There is tags against each i18n
> string and then they will get written out different files (some
> .properties for java, some .xml for flash/flex, some .php for php
> etc...).  We also do some queries where we do a join against this
> table to keep things simple at the database level.  How this looks is:
> SELECT a.activity_id, i."en_US" as name
> FROM  activities a
> JOIN  i18n i ON (a.name_i18n_id = i.i18n_id)
> This means that we have to pass in the locale (en_US) to the query.
> In PHP, Perl, and straight Java this isn't a problem.  But how would
> this easily be accomplished with iBatis?  Do I have to pass in the
> locale as a parameter to *every* query that supports it?  Would there
> be some way of making this automatic and transparent?
> Regards,
> Collin Peters

View raw message