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>
This commit is contained in:
Justin Edmund 2025-09-02 19:46:42 -07:00
parent c33de6f2a6
commit 95ce20bdab
6 changed files with 5664 additions and 2061 deletions

4
i18n.config.ts Normal file
View file

@ -0,0 +1,4 @@
export const locales = ['en', 'ja'] as const
export type Locale = (typeof locales)[number]
export const defaultLocale: Locale = 'en'

9
i18n/navigation.ts Normal file
View file

@ -0,0 +1,9 @@
import {createNavigation} from 'next-intl/navigation'
import {locales, defaultLocale} from '../i18n.config'
export const {Link, useRouter, usePathname, useSearchParams} = createNavigation({
locales,
defaultLocale,
localePrefix: 'as-needed'
})

View file

@ -11,7 +11,9 @@ export default getRequestConfig(async ({requestLocale}) => {
// 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;
const messages = {common, about} as const;
// 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};
});

View file

@ -1,14 +1,15 @@
/** @type {import('next').NextConfig} */
const path = require('path')
const { i18n } = require('./next-i18next.config')
const createNextIntlPlugin = require('next-intl/plugin')
module.exports = {
const withNextIntl = createNextIntlPlugin('./i18n/request.ts')
const nextConfig = {
reactStrictMode: true,
sassOptions: {
prependData: '@import "variables";',
includePaths: [path.join(__dirname, 'styles')],
},
i18n,
async rewrites() {
return [
{
@ -116,3 +117,5 @@ module.exports = {
return config
},
}
module.exports = withNextIntl(nextConfig)

7692
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,7 @@
"meyer-reset-scss": "^2.0.4",
"next": "^14.1.0",
"next-i18next": "^15.1.1",
"next-intl": "^4.3.5",
"next-themes": "^0.2.1",
"nuqs": "^1.15.4",
"pluralize": "^8.0.0",