我在互联网上做了一些研究,文档和其他答案我不能使它工作,所以现在我一无所知。我有一个动态的路线和翻译索引。这是不工作时,建立。路径是/用户/[id]/index.js
export const getStaticPaths = ({ locale }) => {
return {
paths: [
// if no `locale` is provided only the defaultLocale will be generated
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "en" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "hu" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "de" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "lt" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "cz" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "pl" },
{ params: { slug: ["shop", "account", "navbar", "footer"], id: `1` }, locale: "ru" },
],
fallback: true,
}
}
export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ["shop", "account", "navbar", "footer"])),
// Will be passed to the page component as props
},
};
}
//config
i18n: {
// providing the locales supported by your application
locales: ["en", "ru", "hu", "cz", "pl", "de", "lt"],
// default locale used when the non-locale paths are visited
defaultLocale: "en",
localePath: "./lang"
},
1条答案
按热度按时间qv7cva1a1#
从下一个-i18下一个documentation:
默认情况下,next-i18 next希望您的翻译是这样组织的:
因此,如果您切换到
lang
文件夹,请确保:如果你想以自定义的方式构建你的翻译/命名空间,你需要将修改过的localePath和localeStructure值传递到初始化配置中。
此外,请仔细检查是否已将
next-i18next.config.js
配置为: