我试图使用nuxt-i18n来实现我的应用程序的国际化,下面是nuxt-i18n吐露的内容,它工作得很好,但是当我想使用策略时:'no_prefix‘会产生错误.不知道该怎么做,请提出建议。
i18n: {
//strategy: 'no_prefix',
defaultLocale: 'en',
locales: [
{
code: 'en',
name: 'English',
iso: 'en-US',
file: 'english.js'
},
{
code: 'hi',
name: 'Hindi',
file: 'hindi.js'
}
],
lazy: true,
langDir: 'static/locales/'
},
https://nuxt-community.github.io/nuxt-i18n/routing.html#strategy
警告nuxt-i18n在使用no_prefix策略时不支持将非当前区域设置传递给switchLocalePath。
19:39:39
使用localePath策略时不支持将非当前区域设置传递给no_prefix的警告nuxt-i18n。
19:39:39
发布于 2020-05-29 01:19:20
如果您使用的是no_prefix
策略,那么使用模块提供的path
函数将不会带来好处。例如,这2 switchLocalePath
& localePath
在使用no_prefix
时不受支持。就像医生说的:
This implies that you have to rely on browser & cookie detection, and implement locale switches by calling the i18n API.
因此,您应该使用模块提供的API来更改区域设置。我的项目中的一个示例是,当用户希望更改区域设置时,我添加了一个处理程序,并通过调用以下命令来更改区域设置:
this.$i18n.setLocale('en')
或
root.$i18n.setLocale(langCode)
(如果使用复合-api)
https://stackoverflow.com/questions/60758974
复制相似问题