Jiseoup/showmycodePublic
EN|KO
  • Code
  • Commits
  • Pull Requests
← Back to list

chore: refactor error boundaries and add locales barrel export

JiseoupJiseoup · Apr 3, 202673678a9

Files changed3+9 -10

Changed files

+9 -10 · 3

@@ -1,12 +1,7 @@
"use client";
import { useParams } from "next/navigation";
-
-// Inline i18n strings here because error boundaries must be "use client" and cannot call getDictionary (server-only).
-const messages = {
- ko: { title: "데이터를 불러오지 못했습니다.", retry: "다시 시도" },
- en: { title: "Failed to load data.", retry: "Try again" },
-} as const;
+import * as messages from "@/locales";
export default function RepoError({
error,
@@ -20,13 +15,13 @@ export default function RepoError({
return (
<div className="flex-1 flex flex-col items-center justify-center gap-4 text-center px-6">
- <p className="text-sm font-medium">{t.title}</p>
+ <p className="text-sm font-medium">{t.error.title}</p>
<p className="text-xs text-muted-foreground">{error.message}</p>
<button
onClick={unstable_retry}
className="text-xs px-3 py-1.5 rounded border border-border hover:bg-muted transition-colors"
>
- {t.retry}
+ {t.error.retry}
</button>
</div>
);
@@ -19,11 +19,11 @@ export default function GlobalError({
fontFamily: "sans-serif",
}}
>
- <p style={{ fontSize: "14px", fontWeight: 500 }}>Something went wrong.</p>
+ <p style={{ fontSize: "16px", fontWeight: 500 }}>Something went wrong.</p>
<button
onClick={unstable_retry}
style={{
- fontSize: "12px",
+ fontSize: "14px",
padding: "6px 12px",
border: "1px solid #ccc",
borderRadius: "4px",
@@ -0,0 +1,4 @@
+// Re-export all locale dictionaries.
+// When adding a new language: add the locale to lib/i18n.ts and export it here.
+export { default as ko } from "./ko.json";
+export { default as en } from "./en.json";