mirror of
https://github.com/theoludwig/theoludwig.git
synced 2026-05-06 13:48:12 +02:00
21 lines
703 B
TypeScript
21 lines
703 B
TypeScript
import { hasLocale } from "next-intl"
|
|
import { getRequestConfig } from "next-intl/server"
|
|
import { routing } from "./routing.ts"
|
|
|
|
import { LOCALE_DEFAULT } from "@repo/utils/constants"
|
|
import { deepMerge } from "@repo/utils/objects"
|
|
|
|
export default getRequestConfig(async ({ requestLocale }) => {
|
|
const requested = await requestLocale
|
|
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale
|
|
|
|
const userMessages = (await import(`./translations/${locale}.json`)).default
|
|
const defaultMessages = (await import(`./translations/${LOCALE_DEFAULT}.json`)).default
|
|
const messages = deepMerge(defaultMessages, userMessages)
|
|
|
|
return {
|
|
locale,
|
|
messages,
|
|
}
|
|
})
|