返回 CodeWhale
fallback-region.tsx
根目录 / web / components / fallback-region.tsx
1 import type { ReactNode } from "react";
2 import { ENGLISH_ATTRS, fallbackAttrs } from "@/lib/i18n/fallback";
3
4 export function FallbackRegion({
5 path,
6 locale,
7 children,
8 }: {
9 path: string;
10 locale: string;
11 children: ReactNode;
12 }) {
13 const attrs = fallbackAttrs(path, locale);
14 if (!attrs) return <>{children}</>;
15 return (
16 <div className="locale-fallback" {...attrs}>
17 {children}
18 </div>
19 );
20 }
21
22 export function EnglishRegion({ when, children }: { when: boolean; children: ReactNode }) {
23 if (!when) return <>{children}</>;
24 return (
25 <div className="locale-fallback" {...ENGLISH_ATTRS}>
26 {children}
27 </div>
28 );
29 }
30
31 export function EnglishText({ children }: { children: ReactNode }) {
32 return <bdi {...ENGLISH_ATTRS}>{children}</bdi>;
33 }
34
34 lines Plain Text