I would like to mimic the Grails way of resolving i18n messages.
In WEB-INF/i18n/ I have the following directories:
admin/messages_EN.properties
admin/messages_FR.properties
website/messages_EN.properties
website/messages_FR.properties
please ignore the language endings ( EN and FR ) in this example
in my xml configuration I currently have:
<!-- Register the welcome.properties -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="defaultEncoding" value="utf-8" />
<property name="basename" value="/WEB-INF/i18n/" />
</bean>
What I am looking for here, is a way to tell Spring to look for .properties files under i18n but without explicitly telling it what each subdirectory is. That is without a list of basenames that points to /WEB-INF/i18n/admin/ and /WEB-INF/i18n/website/
I want the WEB-INF/i18n/ directory to be dynamic, and that bundles ( directories ) can be created without having to remodify the xml configuration file.
I am not trying to solve this particular example with admin and website sub directories
Is this possible?
Thanks!
解决Spring MVC国际化配置问题
本文探讨了在Spring MVC中实现国际化配置时遇到的问题及解决方案,重点介绍了如何正确配置消息来源,解决找不到国际化消息的问题,并提供了动态加载多语言资源文件的方法。
4926







ReloadableResourceBundleMessageSourceto introduce some sort ofdiscoverproperty that causes the message source to search thebasenamedirectory, instead of loading files directly. – Paul Grime Jun 20 at 10:51