-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] next-intl 기반 다국어(영어/한국어) 지원 세팅 #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9d9d67
1174026
8a3b6f5
6fd6781
3f670fb
357b4bf
ea4ad60
bbacc96
d1db522
247e9bb
8b1a18a
1dcd2f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import "./globals.css"; | ||
| import localFont from "next/font/local"; | ||
| import { notFound } from "next/navigation"; | ||
| import { hasLocale, NextIntlClientProvider } from "next-intl"; | ||
|
|
||
| import type { Metadata } from "next"; | ||
|
|
||
| import { routing } from "@/i18n/routing"; | ||
| import { QueryProvider } from "@/providers/QueryProvider"; | ||
|
|
||
| const pretendard = localFont({ | ||
| src: "../../fonts/PretendardVariable.woff2", | ||
| variable: "--font-family-pretendard", | ||
| weight: "45 920", | ||
| display: "swap", | ||
| }); | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Timo", | ||
| description: "Timo web", | ||
| }; | ||
|
|
||
| interface RootLayoutProps { | ||
| children: React.ReactNode; | ||
| params: Promise<{ locale: string }>; | ||
| } | ||
|
|
||
| export function generateStaticParams() { | ||
| return routing.locales.map((locale) => ({ locale })); | ||
| } | ||
|
|
||
| export default async function RootLayout({ | ||
| children, | ||
| params, | ||
| }: Readonly<RootLayoutProps>) { | ||
| const { locale } = await params; | ||
|
|
||
| if (!hasLocale(routing.locales, locale)) { | ||
| notFound(); | ||
| } | ||
|
|
||
| return ( | ||
| <html lang={locale} className={pretendard.variable}> | ||
| <body> | ||
| <NextIntlClientProvider> | ||
| <QueryProvider>{children}</QueryProvider> | ||
| </NextIntlClientProvider> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| export default function Home() { | ||
| return <>Hi Timo</>; | ||
| return <></>; | ||
| } | ||
|
kimminna marked this conversation as resolved.
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { routing } from "@/i18n/routing"; | ||
| import en from "@/messages/en.json"; | ||
|
|
||
| declare module "next-intl" { | ||
| interface AppConfig { | ||
| Locale: (typeof routing.locales)[number]; | ||
| Messages: typeof en; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { createNavigation } from "next-intl/navigation"; | ||
|
|
||
| import { routing } from "@/i18n/routing"; | ||
|
|
||
| export const { Link, redirect, usePathname, useRouter, getPathname } = | ||
| createNavigation(routing); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { hasLocale } from "next-intl"; | ||
| import { getRequestConfig } from "next-intl/server"; | ||
|
|
||
| import { routing } from "@/i18n/routing"; | ||
|
|
||
| export default getRequestConfig(async ({ requestLocale }) => { | ||
| const requested = await requestLocale; | ||
| const locale = hasLocale(routing.locales, requested) | ||
| ? requested | ||
| : routing.defaultLocale; | ||
|
|
||
| return { | ||
| locale, | ||
| messages: (await import(`../messages/${locale}.json`)).default, | ||
| }; | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineRouting } from "next-intl/routing"; | ||
|
|
||
| export const routing = defineRouting({ | ||
| locales: ["en", "ko"], | ||
| defaultLocale: "en", | ||
| localePrefix: "always", // as-needed 로 추후 변경 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
주석에 만약 스택의 다음 PR에서 바로 고칠 계획이라면 괜찮지만, 그렇지 않다면 지금 반영해주시는 게 좋을 것 같아요. 이 TODO, 제가 대신 처리해드릴까요? 아니면 이슈로 등록해드릴까요? 🤖 Prompt for AI Agents |
||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "Navigation": { | ||
| "home": "Home", | ||
| "today": "Today", | ||
| "focus": "Focus Mode", | ||
| "statistics": "Statistics", | ||
| "settings": "Settings" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "Navigation": { | ||
| "home": "홈", | ||
| "today": "오늘", | ||
| "focus": "집중 모드", | ||
| "statistics": "통계", | ||
| "settings": "설정" | ||
| } | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 미들웨어 파일명이 proxy.ts인데, Next.js는 미들웨어를 middleware.ts로만 인식하는 걸로 알고 있어요. proxy.ts로는 실제로 미들웨어가 동작하지 않을 것 같아서요 middleware.ts로 rename이 필요하지 않을까요?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. middleware -> proxy로 변경이 되었다고 알고 있습니다! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import createMiddleware from "next-intl/middleware"; | ||
|
|
||
| import { routing } from "@/i18n/routing"; | ||
|
|
||
| export default createMiddleware(routing); | ||
|
|
||
| export const config = { | ||
| matcher: ["/((?!api|_next|.*\\..*).*)"], | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
타입 전용 import에는
import type을 붙여주세요.Todo는 타입으로만 쓰이는데, 같은 계층의HomeTodoContainer.tsx(Line 6)는import type { Todo }를 쓰는 반면 여기는 값 import 구문을 그대로 쓰고 있어요. 사소하지만 번들 최적화와 일관성을 위해 맞춰주시면 좋을 것 같습니다.💡 제안
관련 문서: TypeScript -
import type📝 Committable suggestion
🤖 Prompt for AI Agents