Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export default core methods #84

Open
jkomusin opened this issue Feb 28, 2017 · 2 comments
Open

Export default core methods #84

jkomusin opened this issue Feb 28, 2017 · 2 comments

Comments

@jkomusin
Copy link

Hi there, what are your thoughts on exposing the default core methods for use in overriding hooks in manageTranslations? I'd like to be able to augment the default functionality with some of my own pre- or post- behavior, or in some cases overriding it entirely. For example, I'd like to be able to:

import manageTranslations, {
  provideWhitelistFile
} from 'react-intl-translations-manager';

manageTranslations({
  messagesDirectory: 'src/messages/
  translationsDirectory: 'src/translations/',
  languages: ['fr-ca'],
  overrideCoreMethods: {
    provideWhitelistFile: (lang, options) => {
      // Decide whether to do something here
      if (foo === bar) {
        return baz;
      } else {
        // Otherwise do the default thing
        return provideWhitelistFile(lang, options);
      }
    }
  }
});

The API for them would need to change slightly to accept the options that were passed into manageTranslations instead of being closures around the options within manageTranslations itself.

I haven't attempted this yet, but am interested in your appetite for considering such a change. The nice part is that the changes should be backwards compatible: any existing overridden hooks in the wild would already be standalone and ignore the new additional options argument. It would also make these core methods more testable, which could fill the gap in testing around manageTranslations itself.

@harriha
Copy link

harriha commented Apr 20, 2017

This would be indeed nice to have, now the ability to override the hooks is not very useful if the need is to observe the resulting report or augment the output or functionality somehow, the current hook system only supports replacing the default functionality fully.

@SebastienGllmt
Copy link

+1
These hooks are not very useful without this ability and I instead have to rely on hacks to get the behavior I want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants