TootContent: localized

This commit is contained in:
thislight 2024-11-20 16:33:30 +08:00
parent 6313827b1e
commit b1f6033cc8
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
3 changed files with 17 additions and 1 deletions

View file

@ -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<HTMLDivElement> & {
};
const TootContent: Component<TootContentProps> = (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<TootContentProps> = (oprops) => {
});
}}
></span>
<Button onClick={props.onToggleReveal}>"Content Warning"</Button>
<Button onClick={props.onToggleReveal}>{t("cw")}</Button>
</div>
</Show>
<Show when={shouldRevealContent()}>

View file

@ -0,0 +1,3 @@
{
"cw": "\"Content Warning\""
}

View file

@ -0,0 +1,3 @@
{
"cw": "“内容警告”"
}