feat: add Chinese translation for "Download" in i18n data

This commit is contained in:
2025-11-28 19:47:13 +08:00
parent 1a120d2378
commit 4f1600296c
2 changed files with 139 additions and 141 deletions

View File

@@ -261,6 +261,7 @@ export const i18nData = {
"File Size": "文件大小", "File Size": "文件大小",
"Tag": "标签", "Tag": "标签",
"Optional": "可选", "Optional": "可选",
"Download": "下载",
}, },
}, },
"zh-TW": { "zh-TW": {
@@ -525,6 +526,7 @@ export const i18nData = {
"File Size": "檔案大小", "File Size": "檔案大小",
"Tag": "標籤", "Tag": "標籤",
"Optional": "可選", "Optional": "可選",
"Download": "下載",
}, },
}, },
}; };

View File

@@ -465,141 +465,141 @@ function DeleteResourceDialog({
); );
} }
const context = createContext<() => void>(() => {}); const context = createContext<() => void>(() => { });
function Article({ resource }: { resource: ResourceDetails }) { function Article({ resource }: { resource: ResourceDetails }) {
return ( return (
<> <>
<article> <article>
<Markdown <Markdown
remarkPlugins={[remarkGfm]} remarkPlugins={[remarkGfm]}
components={{ components={{
p: ({ node, ...props }) => { p: ({ node, ...props }) => {
if ( if (
typeof props.children === "object" && typeof props.children === "object" &&
(props.children as ReactElement).type === "strong" (props.children as ReactElement).type === "strong"
) { ) {
// @ts-ignore
const child = (
props.children as ReactElement
).props.children.toString() as string;
if (child.startsWith("<iframe")) {
// @ts-ignore // @ts-ignore
let html = child; const child = (
let splits = html.split(" "); props.children as ReactElement
splits = splits.filter((s: string) => { ).props.children.toString() as string;
return !( if (child.startsWith("<iframe")) {
s.startsWith("width") ||
s.startsWith("height") ||
s.startsWith("class") ||
s.startsWith("style")
);
});
html = splits.join(" ");
return (
<div
className={`w-full my-3 max-w-xl rounded-xl overflow-clip ${html.includes("youtube") ? "aspect-video" : "h-48 sm:h-64"}`}
dangerouslySetInnerHTML={{
__html: html,
}}
></div>
);
}
} else if (
typeof props.children === "object" &&
// @ts-ignore
props.children?.props &&
// @ts-ignore
props.children?.props.href
) {
const a = props.children as ReactElement;
const childProps = a.props as any;
const href = childProps.href as string;
// @ts-ignore
if (childProps.children?.length === 2) {
// @ts-ignore
const first = childProps.children[0] as ReactNode;
// @ts-ignore
const second = childProps.children[1] as ReactNode;
if (
typeof first === "object" &&
(typeof second === "string" || typeof second === "object")
) {
const img = first as ReactElement;
// @ts-ignore // @ts-ignore
if (img.type === "img") { let html = child;
return ( let splits = html.split(" ");
<a splits = splits.filter((s: string) => {
className={ return !(
"inline-block card shadow bg-base-100 no-underline hover:shadow-md transition-shadow my-2" s.startsWith("width") ||
} s.startsWith("height") ||
target={"_blank"} s.startsWith("class") ||
href={href} s.startsWith("style")
> );
<figure className={"max-h-96 min-w-48 min-h-24"}> });
{img} html = splits.join(" ");
</figure> return (
<div className={"card-body text-base-content text-lg"}> <div
<div className={"flex items-center"}> className={`w-full my-3 max-w-xl rounded-xl overflow-clip ${html.includes("youtube") ? "aspect-video" : "h-48 sm:h-64"}`}
<span className={"flex-1"}>{second}</span> dangerouslySetInnerHTML={{
<span> __html: html,
<MdOutlineOpenInNew size={24} /> }}
</span> ></div>
);
}
} else if (
typeof props.children === "object" &&
// @ts-ignore
props.children?.props &&
// @ts-ignore
props.children?.props.href
) {
const a = props.children as ReactElement;
const childProps = a.props as any;
const href = childProps.href as string;
// @ts-ignore
if (childProps.children?.length === 2) {
// @ts-ignore
const first = childProps.children[0] as ReactNode;
// @ts-ignore
const second = childProps.children[1] as ReactNode;
if (
typeof first === "object" &&
(typeof second === "string" || typeof second === "object")
) {
const img = first as ReactElement;
// @ts-ignore
if (img.type === "img") {
return (
<a
className={
"inline-block card shadow bg-base-100 no-underline hover:shadow-md transition-shadow my-2"
}
target={"_blank"}
href={href}
>
<figure className={"max-h-96 min-w-48 min-h-24"}>
{img}
</figure>
<div className={"card-body text-base-content text-lg"}>
<div className={"flex items-center"}>
<span className={"flex-1"}>{second}</span>
<span>
<MdOutlineOpenInNew size={24} />
</span>
</div>
</div> </div>
</div> </a>
</a> );
}
}
}
if (href.startsWith("https://store.steampowered.com/app/")) {
const appId = href
.substring("https://store.steampowered.com/app/".length)
.split("/")[0];
if (!Number.isNaN(Number(appId))) {
return (
<div className={"max-w-xl h-52 sm:h-48 my-2"}>
<iframe
className={"scheme-light"}
src={`https://store.steampowered.com/widget/${appId}/`}
></iframe>
</div>
); );
} }
} }
} }
if (href.startsWith("https://store.steampowered.com/app/")) { return <p {...props}>{props.children}</p>;
const appId = href },
.substring("https://store.steampowered.com/app/".length) a: ({ node, ...props }) => {
.split("/")[0]; const href = props.href as string;
if (!Number.isNaN(Number(appId))) { const origin = window.location.origin;
return (
<div className={"max-w-xl h-52 sm:h-48 my-2"}>
<iframe
className={"scheme-light"}
src={`https://store.steampowered.com/widget/${appId}/`}
></iframe>
</div>
);
}
}
}
return <p {...props}>{props.children}</p>;
},
a: ({ node, ...props }) => {
const href = props.href as string;
const origin = window.location.origin;
if (href.startsWith(origin) || href.startsWith("/")) { if (href.startsWith(origin) || href.startsWith("/")) {
let path = href; let path = href;
if (path.startsWith(origin)) { if (path.startsWith(origin)) {
path = path.substring(origin.length); path = path.substring(origin.length);
} }
const content = props.children?.toString(); const content = props.children?.toString();
if (path.startsWith("/resources/")) { if (path.startsWith("/resources/")) {
const id = path.substring("/resources/".length); const id = path.substring("/resources/".length);
for (const r of resource.related ?? []) { for (const r of resource.related ?? []) {
if (r.id.toString() === id) { if (r.id.toString() === id) {
return <RelatedResourceCard r={r} content={content} />; return <RelatedResourceCard r={r} content={content} />;
}
} }
} }
} }
}
return <a target={"_blank"} {...props}></a>; return <a target={"_blank"} {...props}></a>;
}, },
}} }}
> >
{resource.article.replaceAll("\n", " \n")} {resource.article.replaceAll("\n", " \n")}
</Markdown> </Markdown>
</article> </article>
<div className="border-b border-base-300 h-8"></div> <div className="border-b border-base-300 h-8"></div>
<Characters characters={resource.characters} /> <Characters characters={resource.characters} />
</> </>
); );
} }
@@ -898,26 +898,22 @@ function CloudflarePopup({ file }: { file: RFile }) {
<h3 className={"font-bold m-2"}> <h3 className={"font-bold m-2"}>
{downloadToken ? t("Verification successful") : t("Verifying your request")} {downloadToken ? t("Verification successful") : t("Verifying your request")}
</h3> </h3>
{!downloadToken && ( <div className={"h-20 w-full"}>
<> <Turnstile
<div className={"h-20 w-full"}> siteKey={app.cloudflareTurnstileSiteKey!}
<Turnstile onWidgetLoad={() => {
siteKey={app.cloudflareTurnstileSiteKey!} setLoading(false);
onWidgetLoad={() => { }}
setLoading(false); onSuccess={(token) => {
}} setDownloadToken(token);
onSuccess={(token) => { }}
setDownloadToken(token); ></Turnstile>
}} </div>
></Turnstile> <p className={"text-xs text-base-content/80 m-2"}>
</div> {t(
<p className={"text-xs text-base-content/80 m-2"}> "Please check your network if the verification takes too long or the captcha does not appear.",
{t( )}
"Please check your network if the verification takes too long or the captcha does not appear.", </p>
)}
</p>
</>
)}
{downloadToken && ( {downloadToken && (
<div className="p-2"> <div className="p-2">
<a <a