feat: add internationalization message platform

This commit is contained in:
donghyeon-ka
2026-07-26 16:17:39 +09:00
parent b8c0444217
commit 668bf05b48
57 changed files with 1711 additions and 201 deletions
@@ -3,6 +3,7 @@ import {
type ErrorInfo,
type ReactNode,
} from "react";
import { useLocale } from "../i18n/index.js";
type RecoveryResult =
| Readonly<{ action: "reload-once"; releasePair: string }>
@@ -71,27 +72,44 @@ export class ChunkRecoveryBoundary extends Component<Props, State> {
const { error, recovery, reason } = this.state;
if (error && !isChunkLoadFailure(error)) throw error;
if (error && recovery === "checking") {
return (
<section className="ui-page" aria-live="polite" aria-busy="true">
.
</section>
);
return <ChunkRecoverySurface recovery="checking" />;
}
if (error && recovery === "reload-requested") {
return (
<section className="ui-page" aria-live="polite">
.
</section>
);
return <ChunkRecoverySurface recovery="reload-requested" />;
}
if (error && recovery === "support") {
return (
<section className="ui-page" role="alert" data-recovery-reason={reason}>
<h1> .</h1>
<p> .</p>
</section>
);
return <ChunkRecoverySurface recovery="support" reason={reason} />;
}
return this.props.children;
}
}
function ChunkRecoverySurface({
recovery,
reason,
}: Readonly<{
recovery: Exclude<State["recovery"], "idle">;
reason?: string;
}>) {
const { message } = useLocale();
if (recovery === "checking") {
return (
<section className="ui-page" aria-live="polite" aria-busy="true">
{message("chunk.checking")}
</section>
);
}
if (recovery === "reload-requested") {
return (
<section className="ui-page" aria-live="polite">
{message("chunk.reloadOnce")}
</section>
);
}
return (
<section className="ui-page" role="alert" data-recovery-reason={reason}>
<h1>{message("chunk.failure.title")}</h1>
<p>{message("chunk.failure.description")}</p>
</section>
);
}