As part of internationalizing quarkus application, I placed resource bundle properties outside build classpath and now I need my custom resourcebundlemessage interpolator to look for bundles outside classpath by providing the classloader value. By default, message interpolator looks for classloader and since it is null, it is picking the default locale resource bundle. Could someone help me how should I inject classloader to custom message interpolator?
You probably want to use a custom ResourceBundleLocator
:
public class MyResourceBundleLocator implements ResourceBundleLocator {
@Override
public ResourceBundle getResourceBundle(Locale locale) {
// Get the resource bundle from wherever you want.
// Note that resources are retrieved at runtime,
// so you can't access the source/build directories here.
return <your result>;
}
}
@ApplicationScoped
public class MyValidatorFactoryCustomizer implements ValidatorFactoryCustomizer {
@Override
public void customize(BaseHibernateValidatorConfiguration<?> configuration) {
configuration.messageInterpolator(new MyResourceBundleLocator());
}
}