Results 1 to 3 of 3

Thread: DefaultLocale will not activating

  1. #1

    Default DefaultLocale will not activating

    Hi,

    I'm currently managing localization for my site, with a FixedLocaleResolver bean.
    My site is based on jsp (no controller) and rest service, and I'm using <spring:message> tag to get my locale value.
    Code:
    (ex : <spring:message code="page.title"/> )

    When I know the current user locale (ie a message_<locale>.properties exists), my configuration works fine. But when I try to fallback to a default locale because I'm not supporting the language, it doesn't work.

    My configuration (for internationalization) is the following :

    Code:
    <bean id="messageSource"
    		class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    		<property name="basename" value="file:${jetty.home}/resources/message" />
    		<property name="defaultEncoding" value="UTF-8" />
    	</bean>
    
    	<bean id="localeResolver"
    		class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
    		<property name="defaultLocale" value="en_US" />
    	</bean>

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    The fixed locale resolver always resolves to the default locale regardless of what the user has set as a locale. So if you see differences between users that is the strange part.

    Also defaultLocale is only used if there is no locale it isn't the one used if you aren't supporting a locale then a properties file without al ocale is used (messages.properties).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by Marten Deinum View Post
    The fixed locale resolver always resolves to the default locale regardless of what the user has set as a locale. So if you see differences between users that is the strange part.

    Also defaultLocale is only used if there is no locale it isn't the one used if you aren't supporting a locale then a properties file without al ocale is used (messages.properties).
    Thanks for the response. I look again, and it seems that my bean "localeResolver" isn't working (it will not always fallback to my default locale).

    But the second part of your response work for me, so I will do with only ReloadableResourceBundleMessageSource. Thansk a lot.

    Pierrick

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •