Rom*_*man 6 internationalization i18next next.js react-i18next
服务器 Next.js 自动重定向到英语,尽管浏览器有另一种语言 http://localhost:3000/en 而不是 http://localhost:3000。
我的next-i18next.config
module.exports = {
i18n: {
locales: ['ua', 'en', 'ru', 'ar'],
defaultLocale: 'ua',
}
}
Run Code Online (Sandbox Code Playgroud)
浏览器中安装了乌克兰语和英语。一开始是乌克兰语。
Accept-Language在请求标头中:uk,en;q=0.9
如何让它不重定向到英文?我究竟做错了什么?我的package.json
{
"name": "connect-prerelease",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start -p $PORT"
},
"dependencies": {
"@parse/react-ssr": "0.0.1-alpha.14",
"@types/parse": "^2.18.6",
"bootstrap": "^4.6.0",
"next": "10.2.3",
"next-i18next": "^8.5.0",
"next-images": "^1.8.1",
"parse": "^3.2.0",
"react": "17.0.2",
"react-bootstrap": "^1.6.1",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "17.0.11",
"next-compose": "0.0.2",
"typescript": "4.3.2"
}
}
Run Code Online (Sandbox Code Playgroud)
小智 2
试试这个next.config.js:
i18n: {
localeDetection: false
}
Run Code Online (Sandbox Code Playgroud)
参考:i18n 对象
| 归档时间: |
|
| 查看次数: |
4841 次 |
| 最近记录: |