-
Feb 2nd, 2007, 09:05 AM
#1
How to set the Locale for Tag use ?
Hi All,
from my requirement I don't have to use the Locale from the request, but using a business rule.
So I have to use a application-defined Locale for I18N, using the Spring taglib.
But in the source code I found (TagMessageI18N.java):
return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale());
How can I set the Locale in the RequestContext ? As I understand the requestContext harvests the Locale from the request, exactly the opposite I want to perform.
Thank you for your help.
Karlito.
-
Feb 2nd, 2007, 09:12 AM
#2
There is a interceptor which can switch the Locale (conveniently named LocaleChangeInterceptor). The current implementation uses a property on the request to switch the Locale. But you can ofcourse make your own implementation which uses your Business Rule(s).
Hmm just looking a bit further, you can also create a LocalResolver (there is already an abstract class) which you can register in your application context, that in combination with the default LocaleChangeInterceptor will switch your locale.
-
Feb 2nd, 2007, 09:27 AM
#3
ok thanks a lot.
will try to do that :-)
Karlito.
-
Feb 2nd, 2007, 09:39 AM
#4
one more question about LocaleResolver.
(warning, I'm a newbie)
Where do I need to declare my new implementation of LocaleResolver ?
TIA.
Karlito.
-
Feb 2nd, 2007, 04:48 PM
#5
In your applicationContext with the other beans. You have to name it localeResolver and that should do the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules