From 159c46ee15f65195526c3d2e9ed7c593a32293ea Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 29 Nov 2022 08:44:12 +0900 Subject: [PATCH] fix: cannot work locale changing, when we move with `` on `no_prefix` (#1686) --- specs/browser_language_detection/disable.spec.ts | 2 +- src/runtime/utils.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/specs/browser_language_detection/disable.spec.ts b/specs/browser_language_detection/disable.spec.ts index 66b314492..25c615275 100644 --- a/specs/browser_language_detection/disable.spec.ts +++ b/specs/browser_language_detection/disable.spec.ts @@ -41,5 +41,5 @@ test('disable', async () => { await page.waitForTimeout(100) // set default locale - expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('en') + expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('fr') }) diff --git a/src/runtime/utils.ts b/src/runtime/utils.ts index 240a9891f..3adb40d3a 100644 --- a/src/runtime/utils.ts +++ b/src/runtime/utils.ts @@ -240,6 +240,10 @@ export function detectLocale( finalLocale = getLocaleDomain(normalizedLocales) } else if (strategy !== 'no_prefix') { finalLocale = routeLocaleGetter(route) + } else { + if (!nuxtI18nOptions.detectBrowserLanguage) { + finalLocale = initialLocale + } } }