I've been away from Wicket for a year, working on other areas of my client's code. I'm doing a pass by to add i18n to a page. I have a MyPage.properties file with all sorts of properties. I have lots of <wicket:message key="fooBar"> tags in MyPage.html.

But how do I manually look up one of these values from the resources? For example, in MyPage.onAccept() I have something like this:

getSession().success("Successfully munged the " + fooBar + ".");

I want to look up the value from MyPage.properties:

success.message=Successfully munged the {0}.

Looking at the source code of StringResourceModel, it seems I'll have to do the following:

1. Get a localizer.
2. Ask the localizer to get the resource string.
3. Escape single quotes.
4. Escape substitution expressions (e.g. ${some.other.property}).
5. Use MessageFormat to substitute the parameters (e.g. fooBar, above).
6. Unescape the substitution expression.
7. Ask the localizer to perform substitution for all the expressions.


Whew! I'm exhausted just writing that. Surely there is a utility method that would do that for me?

Garret

P.S. A /single/ method. There should be a single method for this.

Reply via email to