Skip to content

Commit

Permalink
fix: cannot work browser locale on no_prefix strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Oct 30, 2022
1 parent da521f2 commit 09546f7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/runtime/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,15 @@ export function detectBrowserLanguage<Context extends NuxtApp = NuxtApp>(
}
}

// get preferred language from cookie if present and enabled
const cookieLocale = getLocaleCookie(context, { ...nuxtI18nOptions.detectBrowserLanguage, localeCodes })
__DEBUG__ && console.log('detectBrowserLanguage cookieLocale', cookieLocale)
__DEBUG__ && console.log('detectBrowserLanguage browserLocale', getBrowserLocale(nuxtI18nInternalOptions, context))

let matchedLocale = cookieLocale
// try to get locale from either navigator or header detection
if (!useCookie) {
let matchedLocale
if (useCookie && (matchedLocale = cookieLocale)) {
// get preferred language from cookie if present and enabled
} else {
// try to get locale from either navigator or header detection
matchedLocale = getBrowserLocale(nuxtI18nInternalOptions, context)
}
__DEBUG__ && console.log('detectBrowserLanguage matchedLocale', matchedLocale)
Expand Down

0 comments on commit 09546f7

Please sign in to comment.