next-intl: I keep getting missing messages errors
Using the latest next 10.x
I have my file setup as:
src
-- messages
-- -- header
-- -- -- en.json
_app has:
MyApp.getInitialProps = async function getInitialProps(context) {
const { locale } = context.router
return {
...(await NextApp.getInitialProps(context)),
messages: require(`../messages/header/${locale}.json`),
}
}
I have checked that it gets locale correctly but console keeps throwing errors:
code: 'MISSING_MESSAGE',
originalMessage: 'No messages available at `undefined`.'
Any ideas what I could be missing here?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (7 by maintainers)
@Pixelatex Did you solve the issue in the end? I am currently seeing this error when running
next build
and have no clue where to start debugging …Your example had an infinite loop. In
App.getInitialProps
you can’t callApp.getInitialProps
again. I changed it to referenceNextApp
now.Yep, when you return something from
App.getInitialProps
, it’s available as a regular prop withinApp
(notpageProps
).Here’s a fixed version https://codesandbox.io/s/next-intl-template-fixed-x2lvm
Does that solve your issue?