Closed sivo1981 closed 1 week ago
Would you be able to provide a reproduction? 🙏
I can't provide reproduction because of SSG so i'm posting logs from both versions. Detect locale from browser should be sl
.
Version: 8.2.0 (working fine)
isSSG true
DKFR7yiG.js:48 useCookie on setup true
DKFR7yiG.js:48 defaultLocale on setup en
DKFR7yiG.js:48 detectLocale: initialLocale - en
DKFR7yiG.js:48 detectLocale: (ssg, callType, firstAccess) - ssg_ignore setup true
DKFR7yiG.js:48 detectBrowserLanguage: (ssg, callType, firstAccess) - ssg_ignore setup true
DKFR7yiG.js:48 detectLocale: detectBrowserLanguage (browserLocale, stat, reason, from) - true detect_ignore_on_ssg undefined
DKFR7yiG.js:48 first detect initial locale en
DKFR7yiG.js:48 final initial locale: en
DKFR7yiG.js:48 locale-changing middleware {fullPath: '/login', hash: '', query: {…}, name: 'login', path: '/login', …} {fullPath: '/', path: '/', query: {…}, hash: '', name: undefined, …}
DKFR7yiG.js:48 detectLocale: initialLocale - en
DKFR7yiG.js:48 detectLocale: (ssg, callType, firstAccess) - ssg_ignore routing true
DKFR7yiG.js:48 detectBrowserLanguage: (ssg, callType, firstAccess) - ssg_ignore routing true
DKFR7yiG.js:48 detectLocale: detectBrowserLanguage (browserLocale, stat, reason, from) - true detect_ignore_on_ssg undefined
DKFR7yiG.js:48 detect locale en
DKFR7yiG.js:48 localeSetup false
DKFR7yiG.js:48 setLocale: new -> en old -> en initial -> false
DKFR7yiG.js:48 detectRedirect: targetLocale -> en
DKFR7yiG.js:48 detectRedirect: route -> {to: {…}, from: {…}}
DKFR7yiG.js:48 detectRedirect: calledWithRouting -> true en
DKFR7yiG.js:48 redirectPath on locale-changing middleware
DKFR7yiG.js:48 navigate options 302 false false false
DKFR7yiG.js:48 navigate isSSG true
DKFR7yiG.js:48 hook app:mounted
DKFR7yiG.js:48 detectBrowserLanguage: (ssg, callType, firstAccess) - ssg_setup setup true
DKFR7yiG.js:48 detectBrowserLanguage: (path, strategy, alwaysRedirect, redirectOn, locale) - / no_prefix false root en
DKFR7yiG.js:48 detectBrowserLanguage: cookieLocale undefined
DKFR7yiG.js:48 getBrowserLocale (navigator.languages, ret) - (2) ['sl', 'en'] sl
DKFR7yiG.js:48 detectBrowserLanguage: browserLocale sl
DKFR7yiG.js:48 detectBrowserLanguage: (matchedLocale, cookieLocale, localeFrom) - sl undefined navigator_or_header
DKFR7yiG.js:48 detectBrowserLanguage: first finaleLocale (finaleLocale, cookieLocale, localeFrom) - sl undefined navigator_or_header
DKFR7yiG.js:48 detectBrowserLanguage: vueI18nLocale en
DKFR7yiG.js:48 app:mounted: detectBrowserLanguage (browserLocale, stat, reason, from) - sl true undefined navigator_or_header
DKFR7yiG.js:48 setLocale: new -> sl old -> en initial -> true
DKFR7yiG.js:48 setLocale: new -> sl old -> sl initial -> true
DKFR7yiG.js:48 detectRedirect: targetLocale -> sl
DKFR7yiG.js:48 detectRedirect: route -> {to: Proxy(Object)}
DKFR7yiG.js:48 detectRedirect: calledWithRouting -> false
DKFR7yiG.js:48 detectRedirect: calculate domain or ssg routePath ->
DKFR7yiG.js:48 redirectPath on setLocale
DKFR7yiG.js:48 navigate options 302 false false true
DKFR7yiG.js:48 navigate isSSG true
DKFR7yiG.js:48 detectRedirect: targetLocale -> sl
DKFR7yiG.js:48 detectRedirect: route -> {to: Proxy(Object)}
DKFR7yiG.js:48 detectRedirect: calledWithRouting -> false
DKFR7yiG.js:48 detectRedirect: calculate domain or ssg routePath ->
DKFR7yiG.js:48 redirectPath on setLocale
DKFR7yiG.js:48 navigate options 302 false false true
DKFR7yiG.js:48 navigate isSSG true
Version: 8.5.0 (not working)
isSSG true
DNsLBDbf.js:48 useCookie on setup true
DNsLBDbf.js:48 defaultLocale on setup en
DNsLBDbf.js:48 getLocaleCookie {useCookie: true, cookieKey: 'locale', localeCodes: Array(2)}
DNsLBDbf.js:48 getLocaleCookie (client) - none
DNsLBDbf.js:48 detectLocale: {initialLocale: 'en'}
DNsLBDbf.js:48 detectBrowserLanguage: {ssg: 'ssg_ignore', callType: 'setup', firstAccess: true}
DNsLBDbf.js:48 detectLocale: {detectBrowserLanguage: {…}}
DNsLBDbf.js:48 first detect initial locale en
DNsLBDbf.js:48 final initial locale: en
DNsLBDbf.js:48 locale-changing middleware {fullPath: '/login', hash: '', query: {…}, name: 'login', path: '/login', …} {fullPath: '/', path: '/', query: {…}, hash: '', name: undefined, …}
DNsLBDbf.js:48 getLocaleCookie {useCookie: true, cookieKey: 'locale', localeCodes: Array(2)}
DNsLBDbf.js:48 getLocaleCookie (client) - none
DNsLBDbf.js:48 detectLocale: {initialLocale: 'en'}
DNsLBDbf.js:48 detectBrowserLanguage: {ssg: 'ssg_ignore', callType: 'routing', firstAccess: true}
DNsLBDbf.js:48 detectLocale: {detectBrowserLanguage: {…}}
DNsLBDbf.js:48 detect locale en
DNsLBDbf.js:48 localeSetup false
DNsLBDbf.js:48 setLocale: new -> en old -> en initial -> false
DNsLBDbf.js:48 detectRedirect: targetLocale -> en
DNsLBDbf.js:48 detectRedirect: route -> {to: {…}, from: {…}}
DNsLBDbf.js:48 detectRedirect: calledWithRouting -> true en
DNsLBDbf.js:48 redirectPath on locale-changing middleware
DNsLBDbf.js:48 navigate options 302 false false false
DNsLBDbf.js:48 navigate isSSG true
DNsLBDbf.js:48 hook app:mounted
DNsLBDbf.js:48 getLocaleCookie {useCookie: true, cookieKey: 'locale', localeCodes: Array(2)}
DNsLBDbf.js:48 getLocaleCookie (client) - locale from cookie: en
DNsLBDbf.js:48 detectBrowserLanguage: {ssg: 'ssg_setup', callType: 'setup', firstAccess: true}
DNsLBDbf.js:48 detectBrowserLanguage: {locale: 'en', path: '/', strategy: 'no_prefix', alwaysRedirect: false, redirectOn: 'root'}
DNsLBDbf.js:48 getBrowserLocale (navigator.languages, ret) - (2) ['sl', 'en'] sl
DNsLBDbf.js:48 detectBrowserLanguage: {locale: 'en', cookieMatch: 'en', browserMatch: 'sl', from: 'cookie'}
DNsLBDbf.js:48 app:mounted: detectBrowserLanguage (locale, reason, from) - (2) ['en', 'cookie']
DNsLBDbf.js:48 setLocale: new -> en old -> en initial -> false
DNsLBDbf.js:48 detectRedirect: targetLocale -> en
DNsLBDbf.js:48 detectRedirect: route -> {to: Proxy(Object)}
DNsLBDbf.js:48 detectRedirect: calledWithRouting -> false
DNsLBDbf.js:48 detectRedirect: calculate domain or ssg routePath ->
DNsLBDbf.js:48 redirectPath on setLocale
DNsLBDbf.js:48 navigate options 302 false false true
DNsLBDbf.js:48 navigate isSSG true
我也出现了这种了问题。
@BobbieGoede
我这里有一个复现, 项目地址为: https://github.com/Zhang-Wei-666/nuxt-i18n-ssg 复现步骤:
pnpm preview
启动预览也可以在这里预览: https://nuxt-i18n-ssg.vercel.app
I have a reproduction here, the project address is: https://github.com/Zhang-Wei-666/nuxt-i18n-ssg Reproduction steps:
pnpm preview
to start the previewYou can also preview it here: https://nuxt-i18n-ssg.vercel.app
Thanks for the reproduction @Zhang-Wei-666 ! I think I have an idea of what could be causing it and may have a fix for it soon.
Environment
Build Modules: -
Reproduction
-
Describe the bug
Detect browser language not working with strategy no_prefix with SSG. When running app in DEV mode on localhost language is detected correctly. When code is generated with
nuxt generate
and copied to server then browser detection doesn't work anymore.This worked fine with version 8.2.0.
After some investigation the problem from logs:
Additional context
No response
Logs
No response