feat: add internationalization message platform
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user