<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <!-- <property name="basename" value="classpath:messages" /> --> <property name="basenames"> <value>/WEB-INF/i18n/messages</value> </property> <property name="cacheSeconds"> <value>60</value> </property> <property name="fallbackToSystemLocale" value="false" /> </bean>Of course you use then taglibs for your content. You never hardcode a string in your application. That will allow you to ship to operations that concern.
... <spring:message code="welcome.loggedIn" /> ...Your properties file will need to live for example in a file like WEB-INF/i18n/messages.properties for the default language or WEB-INF/i18n/messages_de.properties for German in case that is not the default for you. The content is simple key values as we all know:
... welcome.loggedIn=You are logged in as ...A word of advice about Unicode: It can get complicated. For one java Property does not accept unicode. You can find a workaround for that issue as well as several hints to effectively handle Unicode in your app from a previous post I made three years ago.
Now your deployment script just needs to be able to drop the file from your repository into the exploded webapp and your new content will show up in the website. Easy, simple, agile.
No comments:
Post a Comment