TootContent: localized
This commit is contained in:
parent
6313827b1e
commit
b1f6033cc8
3 changed files with 17 additions and 1 deletions
|
@ -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()}>
|
||||||
|
|
3
src/timelines/toots/i18n/en.json
Normal file
3
src/timelines/toots/i18n/en.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"cw": "\"Content Warning\""
|
||||||
|
}
|
3
src/timelines/toots/i18n/zh-Hans.json
Normal file
3
src/timelines/toots/i18n/zh-Hans.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"cw": "“内容警告”"
|
||||||
|
}
|
Loading…
Reference in a new issue