Hi.
I think this is the correct code to bypass the defaultLocale from ResourceBundleMessageInterpolator.
(this is not tested yet).
The point is that you should always call
interpolate on
delegate with the locale parameter, to avoid the default implementation to access its own
defaultLocal.
Note that I haven't tested this yet.
Code:
public class ResourceBundleMessageInterpolator2 implements MessageInterpolator
{
private final MessageInterpolator delegate;
private final Locale defaultLocale;
public ResourceBundleMessageInterpolator2(MessageInterpolator delegate, Locale defaultLocale)
{
this.delegate = delegate;
this.defaultLocale = defaultLocale;
}
@Override
public String interpolate(String message, Context context)
{
return delegate.interpolate(message, context, this.defaultLocale);
}
@Override
public String interpolate(String message, Context context, Locale locale)
{
return delegate.interpolate(message, context, locale);
}
}
the rest of your code seems correct to me.
david