The following code produces a warning in console about missing notification key. Need to be able to suppress disable translation service for custom notifications
const notify = useNotify();
notify("Notification Text", "info");
Console log will display a warning:
Warning: Missing translation for key: "Notification Text"
in Notification (created by Layout)
in Layout (created by WithStyles(Layout))
in WithStyles(Layout) (created by Router.Consumer)
in Router.Consumer (created by withRouter(WithStyles(Layout)))
in withRouter(WithStyles(Layout)) (created by Connect(withRouter(WithStyles(Layout))))
in Connect(withRouter(WithStyles(Layout))) (created by LayoutWithTheme)
in LayoutWithTheme (created by Router.Consumer)
in Router.Consumer (created by Route)
in Route (created by CoreAdminRouter)
in CoreAdminRouter (created by Router.Consumer)
in Router.Consumer (created by Route)
in Route (created by CoreAdmin)
in CoreAdmin (at App.js:26)
in App (at src/鈥媔ndex.js:14)
Maybe this can help you:
https://github.com/marmelab/react-admin/issues/3428#issuecomment-545924943
Even if useNotify is new in v3, the behavior was the same in v2 using the notification saga. And it was not a bug, but a feature. Except that this feature couldn't be disabled in v2, while it's possible to disable it in v3 (as exlained by @WiXSL).
So I'm flagging it as a documentation issue.
Fixed by #3930
I would personally update all the places where useNotify is used as example to indicate that it tries to use a translated message, for example:
https://github.com/marmelab/react-admin/blob/master/docs/Actions.md (see notify('Comment approved'))
https://github.com/marmelab/react-admin/blob/master/docs/List.md
https://github.com/marmelab/react-admin/blob/master/docs/Authentication.md
Was about to open a new issue until I saw this :)
It wasn't clear to me from @WiXSL's answer how to turn this off. I didnt know where to put the code that he's supplied and how to integrate it into my app.
I managed to piece it togther from his code and the ra-i18n-polyglot documentation.
You need to add this to your top level component; the one where you have imported the <Admin> component from react-admin:
import polyglotI18nProvider from "ra-i18n-polyglot";
import englishMessages from "ra-language-english";
const messages = {
en: englishMessages
};
const i18nProvider = polyglotI18nProvider(locale => messages[locale], "en", {
allowMissing: true
});
const App = () => (
<Admin
dataProvider={dataProvider}
dashboard={Dashboard}
authProvider={AuthProvider(authConfig)}
locale="en" // Add this...
i18nProvider={i18nProvider} // ... and this
>
That was a fair bit of time to work out how to tame a feature that I never needed to be turned on in the first place. Still, once it's done, it's done.
Most helpful comment
It wasn't clear to me from @WiXSL's answer how to turn this off. I didnt know where to put the code that he's supplied and how to integrate it into my app.
I managed to piece it togther from his code and the ra-i18n-polyglot documentation.
You need to add this to your top level component; the one where you have imported the
<Admin>component from react-admin:That was a fair bit of time to work out how to tame a feature that I never needed to be turned on in the first place. Still, once it's done, it's done.