Spring i18N

Register Local Resolver

Spring will look for user register localResolver, if not found, spring will use configure AcceptHeaderLocaleResolver as default.


HTTP Request header contains information with key accept-language. This information will send by user browser.




SessionLocaleResolver associate user’s request and retrieve locale and timezone.


If your application does not use session, CookiesLocaleResolver store data in the user browser cookies. 3 properties you can define.

  • cookieName
  • cookieMaxAge
  • cookiePath



Example XML-Based Configuration

<!-- Step 1 define messageSource bean -->

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:messages"/>

<!-- Step 2 define localeResolver bean -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />

<!-- Step 3 define interceptor for locale -->
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i80n.LocaleChangeInterceptor">
       <property name="paramName" value="lang"/>


Complete Code With Java-Based


Spring i18N

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.