balteo
balteo

Reputation: 24679

Spring's ReloadableResourceBundleMessageSource not finding properties file

I have two files under the WEB-INF/i18n directory:

I have properly configured my ReloadableResourceBundleMessageSource bean as follows (spring mvc):

<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application"
        p:fallbackToSystemLocale="false"/>

and yet I get this from Spring mvc:

2012-09-03 02:59:45,911 [http-bio-8080-exec-4] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - Loading properties [application.properties]
2012-09-03 02:59:45,912 [http-bio-8080-exec-4] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [WEB-INF/i18n/application_fr] - neither plain properties nor XML
2012-09-03 02:59:45,912 [http-bio-8080-exec-4] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - Loading properties [messages.properties]
2012-09-03 02:59:45,912 [http-bio-8080-exec-4] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [WEB-INF/i18n/messages_fr] - neither plain properties nor XML

Can anyone please advise? I could move the properties files to the classpath and alter my config accordingly but I'd rather understand what is going on.

Upvotes: 4

Views: 3582

Answers (1)

Solubris
Solubris

Reputation: 3753

In the log message it says this: application_fr

Notice the _fr. This means its trying to look for the french version of the application.properties (application_fr.properties). If it cant find the french properties, it should fall back to the default (application.properties), so your props should still be found. The reason it is looking for the french props is to do with a locale settings somewhere in you app. Could be from browser, JVM, application.

You can try to add the following, to force the locale to english:

<bean class="org.springframework.web.servlet.i18n.FixedLocaleResolver" p:defaultLocale="en"/>   

Upvotes: 1

Related Questions