我在互联网上做了一些研究,根据文档和其他答案,我无法使其发挥作用,所以现在我一无所知。我有一个动态路线并翻译索引。
这在构建时不起作用。
路径是/user/[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"
},