You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bastian Voigt <po...@bastian-voigt.de> on 2008/05/28 15:02:57 UTC

How to Localize persistent Objects

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear *,

in my application I have lots of persistent objects (regions, cities,
countries, etc), from the database which are used in
PropertySelectionModels and other UI elements.

My approach for localizing the names was to give them a "key" field
which is then looked up in a resource bundle properties file by tapestry
(the standard way tapestry does it).

The problem is, each time I add a new city to the database I need to
make a new version of my web app, add the german and english name of the
city to some properties file and deploy it to the server. We have come
to the point where this is becoming unacceptable.

Is there a simple way to have tapestry reload these resource bundles
maybe from an external file without redeploying the application? Or from
a database table?



- --
Bastian Voigt
J2EE Developer
Hamburg, Germany

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPVgB9+lAHD7HULYRAnB9AJ9bDMSW5q2Bec1jfgYESvMqWF2kEACeM7OM
YNp2eHaoKrdx+FpI5k4Ae7k=
=NP9c
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to Localize persistent Objects

Posted by Andreas Andreou <an...@gmail.com>.
1) no need to use spring
2) It's easy if you take a look at the source of
org.apache.tapestry.services.impl.ComponentMessages and its base class
org.apache.hivemind.impl.AbstractMessages

It's then a matter of:
a) overriding public String getMessage(String key) and when the key isn't
found, search in the DB... getLocale() will give you the locale you're
looking for
b) override ComponentMessagesSourceImpl and make Messages
getMessages(IComponent component)
return instances of the class you created in the previous step
c) configure everything in hivemind, so that tapestry uses your
message source instead of its own

On Thu, May 29, 2008 at 11:59 AM, Bastian Voigt <po...@bastian-voigt.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Andreas Andreou wrote:
>
>> http://wiki.apache.org/tapestry/HowTos
>>
>> see the Resources / I18n section
>
> Andreas,
> thank you for the link!
> Two further questions:
>
> 1. Do I need Spring to do it? (we're not using Spring)
>
> 2. I want all my tapestry components and pages to still use the
> localized strings from my .properties files, otherwise I'm a bit afraid
> to lose track of which strings are used by what component/page etc.
>
> The only thing that should come from the DB is the localized names of
> persistent objects, i.e. countries, cities, etc.
>
> - From the Wiki page:
> [LutzHuehnken] asks: If I understand correctly, this will affect *all*
> components. Is there a way to achieve this behaviour just for my own,
> custom components?
>
> Cheers
> Bastian
>
>
> - --
> Bastian Voigt
> Hamburg
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIPnB99+lAHD7HULYRAtG9AJ9xrCU+I2uLUCcn+3kdBpH9NtTc5wCfeta2
> TEytwSnLqGjtYvF8/mdvwoE=
> =oYPW
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to Localize persistent Objects

Posted by Bastian Voigt <po...@bastian-voigt.de>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Andreou wrote:

> http://wiki.apache.org/tapestry/HowTos
> 
> see the Resources / I18n section

Andreas,
thank you for the link!
Two further questions:

1. Do I need Spring to do it? (we're not using Spring)

2. I want all my tapestry components and pages to still use the
localized strings from my .properties files, otherwise I'm a bit afraid
to lose track of which strings are used by what component/page etc.

The only thing that should come from the DB is the localized names of
persistent objects, i.e. countries, cities, etc.

- From the Wiki page:
[LutzHuehnken] asks: If I understand correctly, this will affect *all*
components. Is there a way to achieve this behaviour just for my own,
custom components?

Cheers
Bastian


- --
Bastian Voigt
Hamburg

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPnB99+lAHD7HULYRAtG9AJ9xrCU+I2uLUCcn+3kdBpH9NtTc5wCfeta2
TEytwSnLqGjtYvF8/mdvwoE=
=oYPW
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to Localize persistent Objects

Posted by Bastian Voigt <po...@bastian-voigt.de>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christian Koeberl wrote:
> There are two good practices to do database i18n:
> http://www.theserverside.com/tt/blogs/showblog.tss?id=HibernateInternational

Christian,
thanks a lot for this link, esp. the first one is quite interesting!
I like it because it is really simple to use, once you have setup the
userType mapping you only need to to

<span jwcid="@Insert" value="ognl:country.name"></span>

and all the magic for i18n is done under the hood.
Anyone got something like this running?

Since we use EJB3 / JPA for our persistence I'm just asking myself, will
it be possible to access the current tapestry user's locale in the
persistence layer, and how would you do that.

Cheers
Bastian



> http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/i18n/i18n5.html
> 
> We do quite the same with just one table for all texts.
> 
> Cheers,
> Chris


- --
Bastian Voigt
Hamburg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPnVA9+lAHD7HULYRAgKNAJ4kGKwhfBjmmKc4snNJvlQzJfG/dACeLYBS
eIh3ufmxoX6kD0dCVmupn08=
=dtzv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to Localize persistent Objects

Posted by Christian Koeberl <ch...@porsche.co.at>.
There are two good practices to do database i18n:
http://www.theserverside.com/tt/blogs/showblog.tss?id=HibernateInternational
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/i18n/i18n5.html

We do quite the same with just one table for all texts.

Cheers,
Chris

Re: How to Localize persistent Objects

Posted by Andreas Andreou <an...@gmail.com>.
http://wiki.apache.org/tapestry/HowTos

see the Resources / I18n section

On Wed, May 28, 2008 at 4:02 PM, Bastian Voigt <po...@bastian-voigt.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dear *,
>
> in my application I have lots of persistent objects (regions, cities,
> countries, etc), from the database which are used in
> PropertySelectionModels and other UI elements.
>
> My approach for localizing the names was to give them a "key" field
> which is then looked up in a resource bundle properties file by tapestry
> (the standard way tapestry does it).
>
> The problem is, each time I add a new city to the database I need to
> make a new version of my web app, add the german and english name of the
> city to some properties file and deploy it to the server. We have come
> to the point where this is becoming unacceptable.
>
> Is there a simple way to have tapestry reload these resource bundles
> maybe from an external file without redeploying the application? Or from
> a database table?
>
>
>
> - --
> Bastian Voigt
> J2EE Developer
> Hamburg, Germany
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIPVgB9+lAHD7HULYRAnB9AJ9bDMSW5q2Bec1jfgYESvMqWF2kEACeM7OM
> YNp2eHaoKrdx+FpI5k4Ae7k=
> =NP9c
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org