hensei-web/i18n/request.ts
Justin Edmund 95ce20bdab feat: setup next-intl for App Router i18n support
- Add next-intl package and remove next-i18next
- Configure next-intl plugin in next.config.js
- Create i18n configuration with locale settings
- Setup i18n request handler and navigation utilities
- Define supported locales (en, ja) with English as default

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 19:46:42 -07:00

19 lines
875 B
TypeScript

import {getRequestConfig} from 'next-intl/server'
import {locales, defaultLocale, type Locale} from '../i18n.config'
// next-intl v4: global request config used by getMessages()
export default getRequestConfig(async ({requestLocale}) => {
let locale = (await requestLocale) as Locale | null;
if (!locale || !locales.includes(locale)) {
locale = defaultLocale;
}
// Load only i18n namespaces; exclude content data with dotted keys
const common = (await import(`../public/locales/${locale}/common.json`)).default;
const about = (await import(`../public/locales/${locale}/about.json`)).default;
// Re-include updates.json now that dotted version keys have been renamed (e.g., v1_2_1)
const updates = (await import(`../public/locales/${locale}/updates.json`)).default;
const messages = {common, about, updates} as const;
return {locale, messages};
});