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 "./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()}>
|
||||
|
|
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