I currently have a package on my classpath called MyResources
with multiple property files that Struts uses. Works great:
<constant name="struts.custom.i18n.resources" value="com.company.MyResources"/>
I am trying to move the properties files to a file location, so they can be updated without having to rebuild the package. Is it possible in Struts 2 to refer to this file location?
For example, my new location with the properties files is:
/g01/properties/
And I would like Struts to use that location for the resources.
Yes, by providing an implementation of ResourceBundleTextProvider
and initializing it in your struts.xml
configuration file.
The default implementation, com.opensymphony.xwork2.TextProviderSupport
defers the text lookup to com.opensymphony.xwork2.util.LocalizedTextUtil
.
There are a number of ways to go about this, but if you don't need any of the default S2 behavior, here's the place to start:
<bean type="com.opensymphony.xwork2.TextProvider" name="struts"
class="com.opensymphony.xwork2.TextProviderSupport" scope="default" />
Provide your own ResourceBundleTextProvider
implementation that uses whatever configuration management you want, for example, we implemented a DB-backed version (with caching, of course) that allowed translations to live in, and be managed by, a normal DB and I18N front end.
I'll see if I can dig up my original work this weekend and provide a link to a stripped-down solution.