Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] Modifications to BundleTranslationProvider


as I didn't got any response on my mail, I created ticket and contributed via Gerrit. Maybe my explanation wasn't good enough, and code speaks louder than words. :)

Curious on any feedback.


On Mon, Feb 17, 2014 at 11:46 AM, Dirk Fauth <dirk.fauth@xxxxxxxxx> wrote:

on stackoverflow there was a question on how to modify the default behaviour for loading ResourceBundles. The question was how to do that for the application model and the new message extension aswell.

I showed a way by overriding the BundleLocalization to do a custom loading instead of the default properties file based OSGi loading.

For this I also created a custom TranslationService, as the default BundleTranslationProvider is getting the BundleLocalization by calling ServicesActivator.getDefault().getLocalizationService() instead of getting it injected.

So there are some questions on the BundleTranslationProvider API:

1. Should it be possible for a user to simply extend the BundleTranslationProvider? (it is located in an internal package)
2. Should retrieving the BundleLocalization be modified to get injected instead of calling the ServicesActivator? (not sure if this would have impact in other cases)
3. Should we modify the visibility of getBundle() to protected so it is easier to extend? Or should this even be changed to use the ResourceBundleHelper to avoid duplicated code?

I think the BundleTranslationProvider could simply be changed to look like this.

BundleLocalization localizationService;
public String translate(String key, String contributorURI) {
        if (localizationService == null)
            return key;

        ResourceBundle resourceBundle = ResourceBundleHelper.getResourceBundleForUri(contributorURI,
                ResourceBundleHelper.toLocale(locale), localizationService);
        return getResourceString(key, resourceBundle);

In that case it shouldn't be necessary to override it in most of the cases. But I'm not sure if this would have any side effects.

Because of the current development state, I wanted to ask about this first on the mailing list, before I contribute a patch via Gerrit. Any feedback is welcome!


Back to the top