hensei-web/utils/changeLanguage.tsx
Justin Edmund 007def51a2 Migrate auth components to App Router navigation
- Update LoginModal, SignupModal, and AccountModal to use next/navigation
- Add 'use client' directives to auth components
- Replace router.locale with getCookie('NEXT_LOCALE')
- Update changeLanguage utility to work with App Router
- Replace router.reload() with router.refresh()

All auth flows now use App Router navigation patterns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 16:24:49 -07:00

20 lines
661 B
TypeScript

'use client'
import { setCookie } from 'cookies-next'
import { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime'
export default function changeLanguage(
router: AppRouterInstance,
newLanguage: string
) {
// In App Router, locale handling is different
// We set the cookie and refresh the page to apply the new locale
const expiresAt = new Date()
expiresAt.setDate(expiresAt.getDate() + 60)
setCookie('NEXT_LOCALE', newLanguage, { path: '/', expires: expiresAt })
// App Router doesn't have router.locale or locale option in push
// The locale is handled via the cookie and middleware
router.refresh()
}