This commit is contained in:
hailin 2025-04-22 13:03:26 +08:00
parent 3d27d58abe
commit d85f08fb7a
2 changed files with 0 additions and 5 deletions

View File

@ -26,8 +26,6 @@ export function LanguageSwitcher() {
const isLocaleInPath = i18nConfig.locales.includes(currentLocale as any) const isLocaleInPath = i18nConfig.locales.includes(currentLocale as any)
console.log('[LanguageSwitcher]=>i18nConfig.locales default=', currentLocale)
} }
else{ else{
console.log('[LanguageSwitcher] language switcher cannt running in server.') console.log('[LanguageSwitcher] language switcher cannt running in server.')
@ -41,11 +39,9 @@ export function LanguageSwitcher() {
document.cookie = `preferred-language=${newLocale}; path=/; max-age=31536000` document.cookie = `preferred-language=${newLocale}; path=/; max-age=31536000`
// 同时更新 localStorage // 同时更新 localStorage
console.log('[LanguageSwitcher] Write to localStorage newLocale value:', newLocale)
localStorage.setItem('preferred-language', newLocale) localStorage.setItem('preferred-language', newLocale)
// 验证 cookie 是否成功写入 // 验证 cookie 是否成功写入
console.log('[LanguageSwitcher] Read back to check if cookie value saved?', document.cookie)
const cookieValue = document.cookie const cookieValue = document.cookie
// 更新 i18n 的语言 // 更新 i18n 的语言

View File

@ -18,7 +18,6 @@ export default function HomeRedirector() {
const currentPath = window.location.pathname const currentPath = window.location.pathname
console.log('[HomeRedirector] localStorage preferred:', preferred) console.log('[HomeRedirector] localStorage preferred:', preferred)
console.log('[HomeRedirector] currentPath:', currentPath)
if (!preferred || !isValidLocale(preferred)) { if (!preferred || !isValidLocale(preferred)) {
console.log('[HomeRedirector] No valid preferred language found.') console.log('[HomeRedirector] No valid preferred language found.')