Javascript 实现多语言url nextjs和next-i18n-next
我将要使用next-i18next内部化库 我想知道如何更改url路径的语言。如下所示: /关于我们 /通过ons->转到荷兰版的关于美国页面Javascript 实现多语言url nextjs和next-i18n-next,javascript,reactjs,url,next.js,i18next,Javascript,Reactjs,Url,Next.js,I18next,我将要使用next-i18next内部化库 我想知道如何更改url路径的语言。如下所示: /关于我们 /通过ons->转到荷兰版的关于美国页面 提前感谢!您必须在next.config.js中设置localesubpath const {nextI18NextRewrites} = require('next-i18next/rewrites'); const localeSubpaths = { en: 'en', fr: 'fr', }; module.exports
提前感谢!您必须在next.config.js中设置localesubpath
const {nextI18NextRewrites} = require('next-i18next/rewrites');
const localeSubpaths = {
en: 'en',
fr: 'fr',
};
module.exports = {
rewrites: async () => nextI18NextRewrites(localeSubpaths),
publicRuntimeConfig: {
localeSubpaths,
},
};
next.config.js
const {nextI18NextRewrites} = require('next-i18next/rewrites');
const localeSubpaths = {
en: 'en',
fr: 'fr',
};
module.exports = {
rewrites: async () => nextI18NextRewrites(localeSubpaths),
publicRuntimeConfig: {
localeSubpaths,
},
};
i18n.js
const NextI18Next = require('next-i18next').default;
const {localeSubpaths} = require('next/config').default().publicRuntimeConfig;
const path = require('path');
module.exports = new NextI18Next({
defaultLanguage: 'fr',
otherLanguages: ['en'],
defaultNS: 'common',
browserLanguageDetection: false,
serverLanguageDetection: false,
localeSubpaths,
localePath: path.resolve('./public/locales')
});
你找到什么解决办法了吗?请分享一下好吗?谢谢