feat: improve Bible version selection logic and language switching

- Auto-select appropriate version when switching languages
- Prioritize favorite version only if it matches current locale
- Fall back to locale-specific default version
- Redirect Bible pages to reader root when changing language to allow proper version selection

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-10 10:51:51 +00:00
parent fa72c992f4
commit a756f0808c
2 changed files with 27 additions and 11 deletions

View File

@@ -33,12 +33,22 @@ export function LanguageSwitcher() {
setAnchorEl(null)
}
const handleLanguageChange = (newLocale: string) => {
// Remove current locale from pathname and add new one
const pathWithoutLocale = pathname.replace(`/${locale}`, '') || '/'
const newPath = `/${newLocale}${pathWithoutLocale === '/' ? '' : pathWithoutLocale}`
const handleLanguageChange = async (newLocale: string) => {
// Check if we're on a Bible page
const isBiblePage = pathname.includes('/bible/')
if (isBiblePage) {
// For Bible pages, redirect to Bible reader without specific version
// Let the reader component select appropriate version for the new language
const newPath = `/${newLocale}/bible`
router.push(newPath)
} else {
// For other pages, just change the locale in the URL
const pathWithoutLocale = pathname.replace(`/${locale}`, '') || '/'
const newPath = `/${newLocale}${pathWithoutLocale === '/' ? '' : pathWithoutLocale}`
router.push(newPath)
}
router.push(newPath)
handleClose()
}