I'm trying to call the formatMessage() API directly outside the comp w/o using the standard <FormattedMessage../>
component.
const locale = 'en';
const messages= defineMessages({
greeting: {
id: 'app.greeting',
message:"some message",
defaultMessage: 'Hello,all',
description: 'Greeting to welcome the user to the app',
}
});
const { intl } = new IntlProvider({locale, messages}).getChildContext();
export function someFunc(key, values) {
return intl.formatMessage({id:'greeting'});
}
well the above is static messages defined locally, however I have a translation files, en.json and ja.json globally stored that I would like to load the messages from. How can I do that using the defineMessages, so that when I call the formatMessage() I should be able to see the messages from the resp files depending on the locale selected... ideas appreciated!! Thanks!