- Add daily-verse API endpoint with 7 rotating verses in Romanian and English - Replace static homepage verse with dynamic fetch from API - Ensure consistent daily rotation using day-of-year calculation - Support both ro and en locales for verse content 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6.1 KiB
6.1 KiB
Multi-Language Support Implementation Plan
Overview
Add comprehensive multi-language support to the Ghid Biblic application, starting with English as the second language alongside Romanian.
Current State
- Database: Already supports multiple languages (
langfield) and translations (translationfield) - Frontend: Hardcoded Romanian interface
- Vector Search: Romanian-only search logic
- Bible Data: Only Romanian (FIDELA) version imported
Implementation Phases
Phase 1: Core Infrastructure
-
Install i18n Framework
- Add
next-intlfor Next.js internationalization - Configure locale routing (
/ro/,/en/) - Set up translation file structure
- Add
-
Language Configuration
- Create language detection and switching logic
- Add language persistence (localStorage/cookies)
- Configure default language fallbacks
-
Translation Files Structure
messages/ ├── ro.json (Romanian - existing content) ├── en.json (English translations) └── common.json (shared terms)
Phase 2: UI Internationalization
-
Navigation Component
- Translate all menu items and labels
- Add language switcher dropdown
- Update routing for locale-aware navigation
-
Chat Interface
- Translate all UI text and prompts
- Add suggested questions per language
- Update loading states and error messages
-
Page Content
- Home page (
/→/[locale]/) - Bible browser (
/bible→/[locale]/bible) - Search page (
/search→/[locale]/search) - Prayer requests (
/prayers→/[locale]/prayers)
- Home page (
Phase 3: Backend Localization
-
Vector Search Updates
- Modify search functions to filter by language
- Add language parameter to search APIs
- Update hybrid search for language-specific full-text search
-
Chat API Enhancement
- Language-aware Bible verse retrieval
- Localized AI response prompts
- Language-specific fallback responses
-
API Route Updates
- Add locale parameter to all API endpoints
- Update error responses for each language
- Configure language-specific search configurations
Phase 4: Bible Data Management
-
English Bible Import
- Source: API.Bible or public domain English Bible (KJV/ESV)
- Adapt existing import script for English
- Generate English embeddings using Azure OpenAI
-
Language-Aware Bible Browser
- Add language selector in Bible interface
- Filter books/chapters/verses by selected language
- Show parallel verses when both languages available
Phase 5: Enhanced Features
-
Parallel Bible View
- Side-by-side Romanian/English verse display
- Cross-reference linking between translations
- Language comparison in search results
-
Smart Language Detection
- Auto-detect query language in chat
- Suggest language switch based on user input
- Mixed-language search capabilities
-
Advanced Search Features
- Cross-language semantic search
- Translation comparison tools
- Language-specific biblical term glossaries
Technical Implementation Details
Routing Structure
Current: /page
New: /[locale]/page
Examples:
- /ro/biblia (Romanian Bible)
- /en/bible (English Bible)
- /ro/rugaciuni (Romanian Prayers)
- /en/prayers (English Prayers)
Database Schema Changes
No changes needed - current schema already supports:
- Multiple languages via
langfield - Multiple translations via
translationfield - Unique constraints per translation/language
Vector Search Updates
// Current
searchBibleHybrid(query: string, limit: number)
// Enhanced
searchBibleHybrid(query: string, language: string, limit: number)
Translation File Structure
// messages/en.json
{
"navigation": {
"home": "Home",
"bible": "Bible",
"prayers": "Prayers",
"search": "Search"
},
"chat": {
"placeholder": "Ask your biblical question...",
"suggestions": [
"What does the Bible say about love?",
"Explain the parable of the sower",
"What are the fruits of the Spirit?"
]
}
}
Language Switcher Component
- Dropdown in navigation header
- Flag icons for visual identification
- Persist language choice across sessions
- Redirect to equivalent page in new language
Dependencies to Add
{
"next-intl": "^3.x",
"@formatjs/intl-localematcher": "^0.x",
"negotiator": "^0.x"
}
File Structure Changes
app/
├── [locale]/
│ ├── page.tsx
│ ├── bible/
│ ├── prayers/
│ ├── search/
│ └── layout.tsx
├── api/ (unchanged)
└── globals.css
messages/
├── en.json
├── ro.json
└── index.ts
components/
├── language-switcher.tsx
├── navigation.tsx (updated)
└── chat/ (updated)
Testing Strategy
- Unit Tests: Translation loading and language switching
- Integration Tests: API endpoints with locale parameters
- E2E Tests: Complete user flows in both languages
- Performance Tests: Vector search with language filtering
Rollout Plan
- Development: Implement Phase 1-3 (core infrastructure and UI)
- Testing: Deploy to staging with Romanian/English support
- Beta Release: Limited user testing with feedback collection
- Production: Full release with both languages
- Future: Add additional languages based on user demand
Estimated Timeline
- Phase 1-2: 2-3 days (i18n setup and UI translation)
- Phase 3: 1-2 days (backend localization)
- Phase 4: 2-3 days (English Bible import and embeddings)
- Phase 5: 3-4 days (enhanced features)
- Total: 8-12 days for complete implementation
Success Metrics
- Language switching works seamlessly
- Vector search returns accurate results in both languages
- AI chat responses are contextually appropriate per language
- User can browse Bible in preferred language
- Performance remains optimal with language filtering
Future Considerations
- Spanish, French, German language support
- Regional dialect variations
- Audio Bible integration per language
- Collaborative translation features for community contributions