next.js - Next-i18next 初始语言环境参数未传递到 serverSideTranslations
问题描述
它在本地工作。但是,一旦我将它部署在 firebase 上,它会产生 nextServer 500 内部错误。
next-i18下一个版本
8.1.3
配置
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'ko'],
},
};
代码
_app.tsx
import { appWithTranslation } from 'next-i18next';
const App = ({ Component, pageProps }: AppProps): JSX.Element => {
return (
<Provider store={store}>
<MainWrapper>
<Component {...pageProps} />
</MainWrapper>
</Provider>
);
};
export default appWithTranslation(App);
关于 serverSideRendering 的代码片段
export const getStaticProps: any = async ({ locale }) => ({
props: {
...(await serverSideTranslations(locale, [])),
},
});
export const getServerSideProps: GetServerSideProps = async (context) => {
const { teamId, email } = context.query;
let teamName;
if (!teamId) {
return { props: {} };
}
if (teamId) {
teamName = await getTeamName(teamId as string);
}
return {
props: {
teamId,
teamName,
email: email || '',
...(await serverSideTranslations(context.locale, [])),
},
};
};
解决方案
我有同样的问题,然后我记得我必须在更改文件后手动重新启动 NEXTJS SERVER 。next.config.js
重启服务器帮了我。
推荐阅读
- ansible - 在本地系统上使用 unarchive 模块时出现 ansible 错误
- objective-c - 如何在收入猫上使用超过 1 个产品?
- mongodb - MongoDb Indexes - Equal vs In 过滤器和索引使用
- javascript - 如何在 process.stdin nodejs 上发出事件结束
- dafny - Dafny 断言语句是否具有效力?
- python - Python FFT:频移
- sql - ora-01821 日期格式无法识别
- javascript - 控制多个范围滑块 Django 表单
- python - 打印是 3 的幂的数字。我可以更好地编写这个程序吗?
- python - 我如何使用 tkinter 按钮导入文件