Localized messages in mail.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Localized messages in mail.

Michal Kreuzman
Hi,

what is the best way to handle localization when sending mail with Thymeleaf. I have separate template resolver, template engine and message source for mailing purposes. I try to set email message source to org.thymeleaf.spring3.SpringTemplateEngine but it not works for me.

Thank you
Michal
Reply | Threaded
Open this post in threaded view
|

Re: Localized messages in mail.

danielfernandez
Administrator
Hi,

It depends on the TemplateEngine you are using for processing your emails. If you are using Thymeleaf both for processing web templates AND emails it might be easier for you to use different TemplateEngine instances. For example, you could have these two:

  * A SpringTemplateEngine for your web templates, which by default uses the SpringStandardDialect (and therefore SpringEL for expressions) and the SpringMessageResolver (based on Spring's configured MessageSources, usually pointing to a Messages*.properties set of files).

  * A non-Spring TemplateEngine instance for your emails, which by default uses the StandardDialect (and therefore OGNL for expressions) and resolves messages looking for message .properties files with the same name as the resolved template.

This is just an example configuration, but I find it quite adequate to most applications. You can find an example of the standard message resolution mechanism (.properties files with the same name as the templates) in the "Using Thymeleaf" tutorial and the GTVG example application you can find here: http://www.thymeleaf.org/documentation.html

Regards,
Daniel