From b1f6033cc80154d60912f9a803e62e39fbb9e4cc Mon Sep 17 00:00:00 2001 From: thislight Date: Wed, 20 Nov 2024 16:33:30 +0800 Subject: [PATCH] TootContent: localized --- src/timelines/toots/TootContent.tsx | 12 +++++++++++- src/timelines/toots/i18n/en.json | 3 +++ src/timelines/toots/i18n/zh-Hans.json | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/timelines/toots/i18n/en.json create mode 100644 src/timelines/toots/i18n/zh-Hans.json diff --git a/src/timelines/toots/TootContent.tsx b/src/timelines/toots/TootContent.tsx index f81478b..7a2286d 100644 --- a/src/timelines/toots/TootContent.tsx +++ b/src/timelines/toots/TootContent.tsx @@ -11,6 +11,7 @@ import { resolveCustomEmoji } from "../../masto/toot.js"; import { makeAcctText, useDefaultSession } from "../../masto/clients.js"; import "./TootContent.css"; import { Button } from "@suid/material"; +import { createTranslator } from "../../platform/i18n.jsx"; function preventDefault(event: Event) { event.preventDefault(); @@ -27,6 +28,15 @@ export type TootContentProps = JSX.HTMLAttributes & { }; const TootContent: Component = (oprops) => { + const [t] = createTranslator( + (code) => + import(`./i18n/${code}.json`) as Promise<{ + default: { + cw: string; + }; + }>, + ); + const session = useDefaultSession(); const [props, rest] = splitProps(oprops, [ "source", @@ -81,7 +91,7 @@ const TootContent: Component = (oprops) => { }); }} > - + diff --git a/src/timelines/toots/i18n/en.json b/src/timelines/toots/i18n/en.json new file mode 100644 index 0000000..3d75ddd --- /dev/null +++ b/src/timelines/toots/i18n/en.json @@ -0,0 +1,3 @@ +{ + "cw": "\"Content Warning\"" +} \ No newline at end of file diff --git a/src/timelines/toots/i18n/zh-Hans.json b/src/timelines/toots/i18n/zh-Hans.json new file mode 100644 index 0000000..0e64a62 --- /dev/null +++ b/src/timelines/toots/i18n/zh-Hans.json @@ -0,0 +1,3 @@ +{ + "cw": "“内容警告”" +} \ No newline at end of file