0

Hello I'm trying to do a i18n in: Spring-MVC-Maven configured-by-context.xml project

I have files (path:\src\main\resources):

messages.properties

messages_pl.properties

The app used to work properly when there is only one file -> reads < spring:messages ...> fome the one. But when there are 2 files app reads only messages_pl.properties no mather about ?lang=en.

DispatcherServlet-context.xml

/* [..] */
<mvc:annotation-driven enable-matrix-variables="true"/>
<mvc:resources  location="/resources/"  mapping="/resource/**"/>
<context:component-scan base-package="com.ehr" />

<mvc:interceptors>
    <bean class="com.ehr.webstore.interceptor.PerformanceMonitorInterceptor"/>
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="lang"/>
    </bean>
</mvc:interceptors>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="messages" />
    <property name="defaultEncoding" value="UTF-8"/>
</bean>
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <property name="defaultLocale" value="en"/>
    </bean>
/* [...] */

webpage.jsp

< div class="pull-right" style="padding-right:50px">
    < a href="?lang=en" >en</a>|<a href="?lang=pl" >pl< /a>
< /div>
Community
  • 1
  • 1
ehr
  • 143
  • 1
  • 1
  • 12

1 Answers1

1

Ok, I've found the root of the problem. All in all it's a FallbackToSystemLocale property which by default is setted on "true". For more info check ResourceBundleMessageSource doc.

Solution: added property <property name="fallbackToSystemLocale" value="false"/> to <bean id="messageSource" [...] ResourceBundleMessageSource">

ehr
  • 143
  • 1
  • 1
  • 12