This commit is contained in:
parent
caf341f9cd
commit
1ff10621f1
|
|
@ -35,20 +35,20 @@ export function LanguageSwitcher() {
|
||||||
console.log('[LanguageSwitcher] Saved newLocale to localStorage')
|
console.log('[LanguageSwitcher] Saved newLocale to localStorage')
|
||||||
}
|
}
|
||||||
|
|
||||||
const segments = pathname.split('/')
|
let segments = pathname.split('/').filter(Boolean)
|
||||||
console.log('[LanguageSwitcher] Segments before change:', segments)
|
console.log('[LanguageSwitcher] Segments before change:', segments)
|
||||||
|
|
||||||
const localeList = [...i18nConfig.locales] as string[]
|
const localeList = [...i18nConfig.locales] as string[]
|
||||||
const isLocaleInPath = localeList.includes(segments[1])
|
const isLocaleInPath = localeList.includes(segments[0])
|
||||||
console.log('[LanguageSwitcher] isLocaleInPath:', isLocaleInPath)
|
console.log('[LanguageSwitcher] isLocaleInPath:', isLocaleInPath)
|
||||||
|
|
||||||
if (isLocaleInPath) {
|
if (isLocaleInPath) {
|
||||||
segments[1] = newLocale
|
segments[0] = newLocale
|
||||||
} else {
|
} else {
|
||||||
segments.unshift(newLocale)
|
segments.unshift(newLocale)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newPath = segments.join('/')
|
const newPath = '/' + segments.join('/')
|
||||||
console.log('[LanguageSwitcher] Final newPath:', newPath)
|
console.log('[LanguageSwitcher] Final newPath:', newPath)
|
||||||
|
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue