gpt4 book ai didi

reactjs - react-i18next::您需要使用 initReactI18next 传入一个 i18next 实例

转载 作者:行者123 更新时间:2023-12-04 11:56:38 26 4
gpt4 key购买 nike

react-i18next:: You will need to pass in an i18next instance by using initReactI18next


我最近添加了该包并出现此错误。据我所知,我已按照所有步骤进行操作。
我使用 Next.js 和 next-i18next通常会自动初始化自己的包。
https://github.com/m2vi/downloader

最佳答案

来自 next-i18next docs :

Then we add serverSideTranslation to getStaticProps or getServerSideProps (depending on your case) in our page-level components.


这意味着您需要添加 serverSideTranslation 到需要翻译的页面。

例如在您的 pages/d/[tab]/index文件:
import Head from 'next/head';
import { Input } from '../../../components/Input';
import YouTube from '../../../components/youtube/Main';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

const index = () => {
return (
<>
<Head>
<title>YouTube</title>
</Head>
<YouTube />
</>
);
};

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

export default index;
然后在您的 Main 中进一步下降您可以访问 documentation 的组件翻译使用:
t('pages.documentation')

关于reactjs - react-i18next::您需要使用 initReactI18next 传入一个 i18next 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67894982/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com