At the moment, I use a combination of (1) and (2). A disadvantage of (4) - if I see it correctly - is that I create messages at runtime (f.e. validation error messages) and it would be more complicated in the view if I had to create them at compiletime.
The way I do it now is, I use my own Filter Chain implementation (which looks very similar to the Commons Chain used by Ted Huster in the FormProc controller below) to generate a Locale from the http request/session. This Locale can then be used both in the business logic (if necessary) and in the views. To use the Locale in the view, I use a subclassed FreeMarker servlet that generates a tool that the view can use to load ResourceBundles based on the specified Locale. Freemarker is a template language similar to Velocity, so I guess you can do the same using a Velocity Tool. As for localization, the FreeMarker servlet can use the same Locale to set the default FreeMarker Locale. FreeMarker uses this locale to display dates, currencies, and so forth so if a view displays a date (without specifying a locale) it is automatically formatted using the user's locale. I suspect Velocity can do the same (using a Tool perhaps). If I were to use jsp views in the future, I would be able to do about the same thing, using a taglibrary instead of a Velocity/FreeMarker tool. Using xml as views, the thing would be a little more complicated since (obviously) you can't use Java ResourceBundles in xsl, but I guess it should be possible to include different xsl based on the locale. -----Oorspronkelijk bericht----- Van: Aapo Laakkonen [mailto:[EMAIL PROTECTED] Verzonden: Tuesday, September 23, 2003 4:11 AM Aan: [EMAIL PROTECTED] Onderwerp: [Mav-user] I18n/l10n I would like to know what do you think is the best way to write localized messages in web application. I have a few possibilities: 1. Servlet Filter (outputstream search/replaces) 2. Resource Bundles 3. Database lookups 4. Ant task that does the replaces and deploys each language in it's own dir and then use Maverick's shunting. 5. Add yours. I'm thinking about option 4 as the best alternative. What do you think? ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER] ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]
