Fix Edge-incompatible middleware; set Node runtime on Prisma/pg routes; add full Romanian Bible import + converter; import data JSON; resync RO bookKeys; stabilize /api/bible/books locale fallback; restart dev server.
This commit is contained in:
22
i18n/request.ts
Normal file
22
i18n/request.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { getRequestConfig } from 'next-intl/server'
|
||||
import { headers } from 'next/headers'
|
||||
|
||||
export default getRequestConfig(async () => {
|
||||
// This will be called for each request and determines
|
||||
// which locale to use based on the URL
|
||||
const headersList = await headers()
|
||||
const pathname = headersList.get('x-pathname') || ''
|
||||
|
||||
// Extract locale from pathname (e.g., /en/bible -> en)
|
||||
const segments = pathname.split('/')
|
||||
const locale = segments[1] || 'ro' // Default to Romanian
|
||||
|
||||
// Validate that the locale is supported
|
||||
const supportedLocales = ['en', 'ro']
|
||||
const finalLocale = supportedLocales.includes(locale) ? locale : 'ro'
|
||||
|
||||
return {
|
||||
locale: finalLocale,
|
||||
messages: (await import(`../messages/${finalLocale}.json`)).default
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user