Skip to content

Commit a58aa40

Browse files
committed
refactor: 운영 locale 유지 로직과 순위 모달 문구 국제화 적용
1 parent 9aab357 commit a58aa40

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/features/user/components/user-detail-modal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ActivityGrid } from "./activity-grid"
1414
import { GithubIcon } from "@/shared/components/icons/github-icon"
1515
import { getTierTextColor } from "@/shared/constants/tier-styles"
1616
import { useIsMobile } from "@/shared/hooks/use-media-query"
17+
import { useI18n } from "@/shared/providers/locale-provider"
1718

1819
interface UserDetailModalProps {
1920
username: string | null
@@ -22,6 +23,7 @@ interface UserDetailModalProps {
2223
}
2324

2425
export function UserDetailModal({ username, open, onOpenChange }: UserDetailModalProps) {
26+
const { t } = useI18n()
2527
const { data: user, isLoading, isError } = useUser(username || "", { enabled: !!username && open })
2628
const isMobile = useIsMobile()
2729

@@ -142,7 +144,7 @@ export function UserDetailModal({ username, open, onOpenChange }: UserDetailModa
142144
>
143145
<Link href={`/users/${user.username}`}>
144146
<ExternalLink className="w-4 h-4 mr-2" />
145-
상세 리포트 보기
147+
{t("ranking.modal.view-report")}
146148
</Link>
147149
</Button>
148150
<Button
@@ -152,7 +154,7 @@ export function UserDetailModal({ username, open, onOpenChange }: UserDetailModa
152154
>
153155
<a href={`https://github.com/${user.username}`} target="_blank" rel="noreferrer">
154156
<GithubIcon className="w-4 h-4 mr-2" />
155-
GitHub 방문
157+
{t("ranking.modal.visit-github")}
156158
</a>
157159
</Button>
158160
</div>
@@ -162,4 +164,4 @@ export function UserDetailModal({ username, open, onOpenChange }: UserDetailModa
162164
</DialogContent>
163165
</Dialog>
164166
)
165-
}
167+
}

src/middleware.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ function resolveRequestLocale(request: NextRequest) {
5757
return normalizeLocale(localeFromCookie)
5858
}
5959

60+
const referer = request.headers.get("referer")
61+
if (referer) {
62+
try {
63+
const refererPathname = new URL(referer).pathname
64+
const localeFromRefererPath = getLocaleFromPathname(refererPathname)
65+
if (localeFromRefererPath) {
66+
return localeFromRefererPath
67+
}
68+
} catch {
69+
// ignore invalid referer
70+
}
71+
}
72+
6073
const localeFromHeader = request.headers.get("accept-language")
6174
return normalizeLocale(localeFromHeader)
6275
}

src/shared/i18n/messages/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export const enMessages = {
7676
"ranking.pagination.last": "Last page",
7777
"ranking.item.aria": "{username}, {tier} tier, {score} points, rank {rank}",
7878
"ranking.avatar.alt": "{username} profile image",
79+
"ranking.modal.view-report": "View detailed report",
80+
"ranking.modal.visit-github": "Visit GitHub",
7981
"profile.refresh.available-now": "Available now",
8082
"profile.refresh.available-soon": "Available soon",
8183
"profile.refresh.available-in": "Available in {minutes}m {seconds}s",

src/shared/i18n/messages/ko.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export const koMessages: Record<MessageKey, string> = {
7777
"ranking.pagination.last": "마지막 페이지",
7878
"ranking.item.aria": "{username}, {tier} 티어, {score}점, {rank}위",
7979
"ranking.avatar.alt": "{username}의 프로필 이미지",
80+
"ranking.modal.view-report": "상세 리포트 보기",
81+
"ranking.modal.visit-github": "GitHub 방문",
8082
"profile.refresh.available-now": "지금 갱신 가능",
8183
"profile.refresh.available-soon": "잠시 후 가능",
8284
"profile.refresh.available-in": "{minutes}분 {seconds}초 후 가능",

0 commit comments

Comments
 (0)