我正在做一个Nuxt.js项目,它使用@ nuxtjs/i18n模块实现了国际化(i18n).我想直接以法语(默认区域设置)提供页面,而不重定向到/fr/.当在URL中没有提供特定区域时(例如,访问/place应该以法语提供页面,而不重定向到/fr/place).然而,尽管我的配置,重定向仍然发生.
下面是我的nuxt. config. ts配置:
import { defineNuxtConfig } from 'nuxt/config'
export default defineNuxtConfig({
// Other configurations...
i18n: {
detectBrowserLanguage: {
useCookie: true,
cookieCrossOrigin: true,
cookieKey: 'i18n_redirected',
redirectOn: 'root'
},
strategy: 'prefix',
locales: [
{ name: 'English', code: 'en', iso: 'en-US', dir: 'ltr', file: 'en.json' },
{ name: 'Français', code: 'fr', iso: 'fr-FR', dir: 'ltr', file: 'fr.json' },
{ name: 'العربية', code: 'ar', iso: 'ar-AR', dir: 'rtl', file: 'ar.json' },
],
defaultLocale: 'fr',
vueI18n: './i18n.config.ts'
},
// Other configurations...
});
我已try 清除浏览器cookie,判断浏览器语言设置,并验证没有冲突的设置或中间件影响路由行为,但问题仍然存在.
关于如何直接在默认区域设置中提供页面而不重定向到区域设置前缀的URL有什么 idea ?