微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

next-18next 与最新 nextjs 集成时出错:在没有 next-i18next 配置的情况下调用了 appWithTranslation

如何解决next-18next 与最新 nextjs 集成时出错:在没有 next-i18next 配置的情况下调用了 appWithTranslation

我正在将今天的应用升级到最新的 nextjs 版本 (10.0.9)。

为了移动翻译,我使用了 next-i18next lib 及其来自 Github 的简单示例。

但是,在我的应用程序中,我总是遇到下一个错误

enter image description here

在next-i18next lib的调试器上,我发现在没有提供i18n config的情况下抛出这个错误

在我的应用配置中看起来像:

nextjs.config.js

nextjs.config.js

next-i18next.config.js

enter image description here

_app.js

const HeadstartApp = (props) => {
const { Component,apollo,redux,theme } = props;
  const reduxRef = useRef(initRedux(redux));
  const apolloRef = useRef(
    getApolloClient()
  );
return (
    <React.Fragment>
      <Head>
        <title>Example</title>
        <Meta
          name='viewport'
          content='minimum-scale=1,initial-scale=1,width=device-width'
        />
      </Head>
     
      <ApolloProvider client={apolloRef.current}>
        <Provider store={reduxRef.current}>
          <div dir={locale === 'he' ? 'rtl' : 'ltr'}>
            <ThemeProvider theme={createMuiTheme(theme)}>
              {/* <AppBar position={'static'}>
            <Toolbar>
              <Typography>
                <h1>{locale}</h1>
              </Typography>
              <Link href='/projects/construction/1'>
                <Button>Project 1</Button>
              </Link>
              <Link href='/projects/digital/2'>
                <Button>Project 2</Button>
              </Link>
            </Toolbar>
          </AppBar> */}

              <Layout {...props}>
                <Component {...props} />
              </Layout>
            </ThemeProvider>
          </div>
        </Provider>
      </ApolloProvider>
    </React.Fragment>
  );
};
    }
export default appWithTranslation(HeadstartApp);

index.js

const HomePage = (props) => {
...code
}

export const getStaticProps = async ({ locale,defaultLocale }) => ({
  props: {
    ...(await serverSideTranslations(locale || defaultLocale,[
      'common','homepage',])),},});

export default HomePage;

看起来我的应用程序与简单示例 here 具有相同的配置,但抛出了这个奇怪的异常。 有人得到了一些东西,可以帮助解决

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?