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 { makeAcctText, useDefaultSession } from "../../masto/clients.js";
import "./TootContent.css"; import "./TootContent.css";
import { Button } from "@suid/material"; import { Button } from "@suid/material";
import { createTranslator } from "../../platform/i18n.jsx";
function preventDefault(event: Event) { function preventDefault(event: Event) {
event.preventDefault(); event.preventDefault();
@ -27,6 +28,15 @@ export type TootContentProps = JSX.HTMLAttributes<HTMLDivElement> & {
}; };
const TootContent: Component<TootContentProps> = (oprops) => { const TootContent: Component<TootContentProps> = (oprops) => {
const [t] = createTranslator(
(code) =>
import(`./i18n/${code}.json`) as Promise<{
default: {
cw: string;
};
}>,
);
const session = useDefaultSession(); const session = useDefaultSession();
const [props, rest] = splitProps(oprops, [ const [props, rest] = splitProps(oprops, [
"source", "source",
@ -81,7 +91,7 @@ const TootContent: Component<TootContentProps> = (oprops) => {
}); });
}} }}
></span> ></span>
<Button onClick={props.onToggleReveal}>"Content Warning"</Button> <Button onClick={props.onToggleReveal}>{t("cw")}</Button>
</div> </div>
</Show> </Show>
<Show when={shouldRevealContent()}> <Show when={shouldRevealContent()}>

View file

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

View file

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