Fork me on GitHub

HST-2 Repository ResourceBundle MessageSource

Configuration

If you want to take advantage of HST-2 Repository Dynamic ResourceBundle as MessageSource in your Spring Framework application, then you should configure the following MessageSource bean instead of the default ResourceBundleMessageSource.

<beans>

  <!-- SNIP -->

  <!-- Set HstRepositoryResourceBundleMessageSource to be able to use HST-2 Repository Dynamic Resource Bundles. -->
  <bean id="messageSource" class="org.onehippo.forge.hst.spring.support.HstRepositoryResourceBundleMessageSource">
    <!--
      You don't have to specify hard-coded 'basenames' property here,
      but you can still add some standard Java resource bundle basenames additionally.
      So, in this example, if a resource key is not found from the bundle(s) configured in
      HST-2 configuration (hst:sitemapitem, hst:mount, hst:virtualhost or hst:virtualhosts as ordered by precedence), then it may fall
      back to the specified Java standard resource bundle (e.g, 'classpath:org/hippoecm/hst/demo/spring/webmvc/exceptions_en.properties').
    -->
    <property name="basenames">
      <list>
        <value>org.hippoecm.hst.demo.spring.webmvc.exceptions</value>
      </list>
    </property>
  </bean>

  <!-- SNIP -->

</beans>
        

See the Javadoc of HstRepositoryResourceBundleMessageSource for more detail.