Okay so in my case it was due to SSR.
In addition of the "locale" Provider which allow language switching.
I've added to my _document.jsx
a Provider which get the locale from the router.
class MyDocument extends Document<TDocumentInitialProps> {
static async getInitialProps(ctx: DocumentContext): Promise<TDocumentInitialProps> {
const messages = (await importMessages(ctx.locale)) as Record<string, string> | Record<string, MessageFormatElement[]>;
return {
locale: ctx.locale,
messages,
};
}
render(): JSX.Element {
const { locale, messages } = this.props;
return (
<IntlProvider locale={locale} messages={messages}>
<Html lang={locale}>
<Head>
<link rel="icon" href="/images/layout/favicon.png" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
</IntlProvider>
);
}
}
export default MyDocument;