为了翻译我的网站,我intl在 layout.js 文件中注入了这样的内容:
import React from "react";
import { injectIntl } from "gatsby-plugin-intl";
const Layout = ({intl}) => (
    {intl.formatMessage({id: "history_text"})}
);
export default injectIntl(Layout)
但是在我添加gatsby-plugin-layout到我的项目之后(基于这个例子)我得到了这个错误:
Error: [React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.
如何在保留翻译的同时摆脱此错误?
这是相关的 gatsby 配置部分:
{
    resolve: `gatsby-plugin-intl`,
    options: {
        path: `${__dirname}/src/locale`,
        languages: [`en`, `de`],
        defaultLanguage: `de`,
        redirect: false,
    },
},
{
    resolve: `gatsby-plugin-layout`,
    options: {
        component: require.resolve(`./src/components/layout.js`),
    },
},