I think I found another way...
I noticed that IStringResourceLoader
also has a method String loadStringResource(Class<?> clazz, String key, Locale locale, String style);
(and one more parameter for variation in newer Wicket versions) which does not require a component. clazz
is supposed to be a component class, but... it doesn't actually have to be :)
I was able to implement my own class MyLocalizer extends Localizer
with a new method
getString(String key, Class<?> cl, IModel<?> model, Locale locale, String defaultValue)
which works in a similar way to
getString(String key, Component component, IModel<?> model, String defaultValue)
but uses the class directly instead of a component. It still uses the same properties cache and resource loaders.
Then I wrote an abstract class MyConverter implements IConverter
which has a MyLocalizer getLocalizer()
and a few getString
methods like the Component
class. Basically it does getLocalizer().getString(key, getClass(), model, locale, defaultValue)
, so the properties can now be attached to the converter class.
Seems to work :)