Folks,
At present we use a set of standard properties files with Struts 2.x to provide our I18N functionality - and for the most part, these do exactly what we need them to. However, there are occasions when it would be great to be able to have individual properties reference other properties in the resource bundle, for example:
name.first=John
name.last=Doe
name.full={name.first} {name.last}
I am aware of several extensions to java.util.Properties that provide these sorts of capabilities such as:
I was wondering if anyone has ever attempted to integrate these somehow into Struts 2.x - is it possible to override the mechanism which handles the parsing of resource bundles?
There's nothing like this built-in, but IIRC you can set a text provider via:
<bean type="com.opensymphony.xwork2.TextProvider" name="struts"
class="com.opensymphony.xwork2.TextProviderSupport" scope="default" />
I've never actually done this, but it's a worthy, interesting experiment.
Properties may include arbitrary OGNL, however–you can fake it (verbosely) in the meantime:
name.first=John
name.last=Doe
name.full=%{getText('name.first')} %{getText('name.last')}
(You may also use ${...}, but I prefer %{...} so it's clear it's OGNL.)
I've bookmarked this question for research, there are several cool ideas here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With