From 4f1600296c4590dd6246af85ea1f9c202af08b3c Mon Sep 17 00:00:00 2001 From: nyne Date: Fri, 28 Nov 2025 19:47:13 +0800 Subject: [PATCH] feat: add Chinese translation for "Download" in i18n data --- frontend/src/i18n.ts | 2 + frontend/src/pages/resource_details_page.tsx | 278 +++++++++---------- 2 files changed, 139 insertions(+), 141 deletions(-) diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 6c34543..d0dec47 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -261,6 +261,7 @@ export const i18nData = { "File Size": "文件大小", "Tag": "标签", "Optional": "可选", + "Download": "下载", }, }, "zh-TW": { @@ -525,6 +526,7 @@ export const i18nData = { "File Size": "檔案大小", "Tag": "標籤", "Optional": "可選", + "Download": "下載", }, }, }; diff --git a/frontend/src/pages/resource_details_page.tsx b/frontend/src/pages/resource_details_page.tsx index 45f48c3..c4d92a5 100644 --- a/frontend/src/pages/resource_details_page.tsx +++ b/frontend/src/pages/resource_details_page.tsx @@ -465,141 +465,141 @@ function DeleteResourceDialog({ ); } -const context = createContext<() => void>(() => {}); +const context = createContext<() => void>(() => { }); function Article({ resource }: { resource: ResourceDetails }) { return ( <> -
- { - if ( - typeof props.children === "object" && - (props.children as ReactElement).type === "strong" - ) { - // @ts-ignore - const child = ( - props.children as ReactElement - ).props.children.toString() as string; - if (child.startsWith(" + { + if ( + typeof props.children === "object" && + (props.children as ReactElement).type === "strong" + ) { // @ts-ignore - let html = child; - let splits = html.split(" "); - splits = splits.filter((s: string) => { - return !( - s.startsWith("width") || - s.startsWith("height") || - s.startsWith("class") || - s.startsWith("style") - ); - }); - html = splits.join(" "); - return ( -
- ); - } - } 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; + const child = ( + props.children as ReactElement + ).props.children.toString() as string; + if (child.startsWith(" -
- {img} -
-
-
- {second} - - - + let html = child; + let splits = html.split(" "); + splits = splits.filter((s: string) => { + return !( + s.startsWith("width") || + s.startsWith("height") || + s.startsWith("class") || + s.startsWith("style") + ); + }); + html = splits.join(" "); + return ( +
+ ); + } + } 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 ( + +
+ {img} +
+
+
+ {second} + + + +
-
- + + ); + } + } + } + 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 ( +
+ +
); } } } - 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 ( -
- -
- ); - } - } - } - return

{props.children}

; - }, - a: ({ node, ...props }) => { - const href = props.href as string; - const origin = window.location.origin; + return

{props.children}

; + }, + a: ({ node, ...props }) => { + const href = props.href as string; + const origin = window.location.origin; - if (href.startsWith(origin) || href.startsWith("/")) { - let path = href; - if (path.startsWith(origin)) { - path = path.substring(origin.length); - } - const content = props.children?.toString(); - if (path.startsWith("/resources/")) { - const id = path.substring("/resources/".length); - for (const r of resource.related ?? []) { - if (r.id.toString() === id) { - return ; + if (href.startsWith(origin) || href.startsWith("/")) { + let path = href; + if (path.startsWith(origin)) { + path = path.substring(origin.length); + } + const content = props.children?.toString(); + if (path.startsWith("/resources/")) { + const id = path.substring("/resources/".length); + for (const r of resource.related ?? []) { + if (r.id.toString() === id) { + return ; + } } } } - } - return ; - }, - }} - > - {resource.article.replaceAll("\n", " \n")} - -
-
- + return ; + }, + }} + > + {resource.article.replaceAll("\n", " \n")} + + +
+ ); } @@ -898,26 +898,22 @@ function CloudflarePopup({ file }: { file: RFile }) {

{downloadToken ? t("Verification successful") : t("Verifying your request")}

- {!downloadToken && ( - <> -
- { - setLoading(false); - }} - onSuccess={(token) => { - setDownloadToken(token); - }} - > -
-

- {t( - "Please check your network if the verification takes too long or the captcha does not appear.", - )} -

- - )} +
+ { + setLoading(false); + }} + onSuccess={(token) => { + setDownloadToken(token); + }} + > +
+

+ {t( + "Please check your network if the verification takes too long or the captcha does not appear.", + )} +

{downloadToken && (
- +

{character.name} @@ -2123,7 +2119,7 @@ function CharacterCard({ character }: { character: CharacterParams }) { ) : null }

- + {character.cv && (