Announcement Announcement Module
Collapse
No announcement yet.
(Reloadable)ResourceBundleMessageSource - default Locale Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • (Reloadable)ResourceBundleMessageSource - default Locale

    How can I tell Spring to use a specific (default) Locale during start-up of the app other than the OS' locale?

    I want the app to use en_US when it is started but when the user selects another Locale from a dropdown list this Locale shall be set for all further pages until another language/locale will be chosen.

    Should I use ResourceBundleMessageSource or ReloadableResourceBundleMessagesource?

    The properties file/ResourceBundles are located in package com.xxx.support.

    In my ApplicationContext I have defined these beans:

    - localeChangeInterceptor (referenced in the mappings bean in action-servlet.xml)
    - messageSource
    - viewResolver (is thi sneccessary?)
    - localeResolver (is this neccessary?)

    Thank you,
    Dirk

  • #2
    Hey Dirk,

    Believe it or not, but it seems Spring MVC needs to need a little change in its LocaleResolver implementation to support this.

    http://opensource.atlassian.com/proj...rowse/SPR-2382

    Are you using Spring 2.0?

    Comment


    • #3
      Originally posted by devijvers
      Hey Dirk,

      Believe it or not, but it seems Spring MVC needs to need a little change in its LocaleResolver implementation to support this.

      http://opensource.atlassian.com/proj...rowse/SPR-2382

      Are you using Spring 2.0?
      No, it's Spring 1.2.8

      Comment


      • #4
        I will add a "defaultLocale" property to both CookieLocaleResolver and SessionLocaleResolver, used as fallback if specified (instead of the request's accept-header locale). This will be released in 2.0 RC3 and 1.2.9.

        For the time being, consider implementing your own LocaleResolver (potentially deriving from one of the pre-built LocaleResolver impls). After all, LocaleResolver is explicitly designed as strategy interface that allows for custom implementations.

        Juergen

        Comment


        • #5
          Implementing my own LocaleResolver

          Originally posted by Juergen Hoeller
          I will add a "defaultLocale" property to both CookieLocaleResolver and SessionLocaleResolver, used as fallback if specified (instead of the request's accept-header locale). This will be released in 2.0 RC3 and 1.2.9.

          For the time being, consider implementing your own LocaleResolver (potentially deriving from one of the pre-built LocaleResolver impls). After all, LocaleResolver is explicitly designed as strategy interface that allows for custom implementations.

          Juergen
          Well, I have already tried to do so but where do I have to tell Spring (or the LocaleResolver) that there is another property definded in the ApplicationContext(.xml) to consider? Where do I get the default-locale from when implementing SessionLocaleResolver.resolveLocale(HttpServletReq uest)?

          Thank you,
          Dirk

          Comment

          Working...
          X