chore: improve i18n

This commit is contained in:
Fu Diwei
2024-10-14 21:00:50 +08:00
parent 9bd279a8a0
commit e397793153
69 changed files with 1866 additions and 1509 deletions

View File

@@ -8,7 +8,7 @@ import { useEffect, useState } from "react";
import { update } from "@/repository/settings";
import { getErrMessage } from "@/lib/error";
import { useToast } from "../ui/use-toast";
import { useTranslation } from 'react-i18next'
import { useTranslation } from "react-i18next";
type DingTalkSetting = {
id: string;
@@ -72,15 +72,17 @@ const DingTalk = () => {
setChannels(resp);
toast({
title: t('save.succeed'),
description: t('setting.notify.config.save.succeed'),
title: t("common.save.succeeded.message"),
description: t("settings.notification.config.saved.message"),
});
} catch (e) {
const msg = getErrMessage(e);
toast({
title: t('save.failed'),
description: `${t('setting.notify.config.save.failed')}: ${msg}`,
title: t("common.save.failed.message"),
description: `${t(
"settings.notification.config.failed.message"
)}: ${msg}`,
variant: "destructive",
});
}
@@ -102,7 +104,7 @@ const DingTalk = () => {
}}
/>
<Input
placeholder={t('access.form.ding.access.token.placeholder')}
placeholder={t("settings.notification.dingtalk.secret.placeholder")}
className="mt-2"
value={dingtalk.data.secret}
onChange={(e) => {
@@ -129,7 +131,9 @@ const DingTalk = () => {
});
}}
/>
<Label htmlFor="airplane-mode">{t('setting.notify.config.enable')}</Label>
<Label htmlFor="airplane-mode">
{t("settings.notification.config.enable")}
</Label>
</div>
<div className="flex justify-end mt-2">
@@ -138,7 +142,7 @@ const DingTalk = () => {
handleSaveClick();
}}
>
{t('save')}
{t("common.save")}
</Button>
</div>
</div>

View File

@@ -9,7 +9,7 @@ import {
} from "@/domain/settings";
import { getSetting, update } from "@/repository/settings";
import { useToast } from "../ui/use-toast";
import { useTranslation } from 'react-i18next'
import { useTranslation } from "react-i18next";
const NotifyTemplate = () => {
const [id, setId] = useState("");
@@ -68,8 +68,8 @@ const NotifyTemplate = () => {
}
toast({
title: t('save.succeed'),
description: t('setting.notify.template.save.succeed'),
title: t("common.save.succeeded.message"),
description: t("settings.notification.template.saved.message"),
});
};
@@ -83,7 +83,7 @@ const NotifyTemplate = () => {
/>
<div className="text-muted-foreground text-sm mt-1">
{t('setting.notify.template.variables.tips.title')}
{t("settings.notification.template.variables.tips.title")}
</div>
<Textarea
@@ -94,10 +94,10 @@ const NotifyTemplate = () => {
}}
></Textarea>
<div className="text-muted-foreground text-sm mt-1">
{t('setting.notify.template.variables.tips.content')}
{t("settings.notification.template.variables.tips.content")}
</div>
<div className="flex justify-end mt-2">
<Button onClick={handleSaveClick}>{t('save')}</Button>
<Button onClick={handleSaveClick}>{t("common.save")}</Button>
</div>
</div>
);

View File

@@ -50,7 +50,7 @@ const Telegram = () => {
const data = getDetailTelegram();
setTelegram({
id: config.id ?? "",
name: "telegram",
name: "common.provider.telegram",
data,
});
}, [config]);
@@ -72,15 +72,17 @@ const Telegram = () => {
setChannels(resp);
toast({
title: t('save.succeed'),
description: t('setting.notify.config.save.succeed'),
title: t("common.save.succeeded.message"),
description: t("settings.notification.config.saved.message"),
});
} catch (e) {
const msg = getErrMessage(e);
toast({
title: t('save.failed'),
description: `${t('setting.notify.config.save.failed')}: ${msg}`,
title: t("common.save.failed.message"),
description: `${t(
"settings.notification.config.failed.message"
)}: ${msg}`,
variant: "destructive",
});
}
@@ -130,7 +132,9 @@ const Telegram = () => {
});
}}
/>
<Label htmlFor="airplane-mode">{t('setting.notify.config.enable')}</Label>
<Label htmlFor="airplane-mode">
{t("settings.notification.config.enable")}
</Label>
</div>
<div className="flex justify-end mt-2">
@@ -139,7 +143,7 @@ const Telegram = () => {
handleSaveClick();
}}
>
{t('save')}
{t("common.save")}
</Button>
</div>
</div>

View File

@@ -9,7 +9,7 @@ import { update } from "@/repository/settings";
import { getErrMessage } from "@/lib/error";
import { useToast } from "../ui/use-toast";
import { isValidURL } from "@/lib/url";
import { useTranslation } from 'react-i18next'
import { useTranslation } from "react-i18next";
type WebhookSetting = {
id: string;
@@ -61,8 +61,8 @@ const Webhook = () => {
webhook.data.url = webhook.data.url.trim();
if (!isValidURL(webhook.data.url)) {
toast({
title: t('save.failed'),
description: t('setting.notify.config.save.failed.url.not.valid'),
title: t("common.save.failed.message"),
description: t("settings.notification.url.errmsg.invalid"),
variant: "destructive",
});
return;
@@ -81,15 +81,17 @@ const Webhook = () => {
setChannels(resp);
toast({
title: t('save.succeed'),
description: t('setting.notify.config.save.succeed'),
title: t("common.save.succeeded.message"),
description: t("settings.notification.config.saved.message"),
});
} catch (e) {
const msg = getErrMessage(e);
toast({
title: t('save.failed'),
description: `${t('setting.notify.config.save.failed')}: ${msg}`,
title: t("common.save.failed.message"),
description: `${t(
"settings.notification.config.failed.message"
)}: ${msg}`,
variant: "destructive",
});
}
@@ -125,7 +127,9 @@ const Webhook = () => {
});
}}
/>
<Label htmlFor="airplane-mode">{t('setting.notify.config.enable')}</Label>
<Label htmlFor="airplane-mode">
{t("settings.notification.config.enable")}
</Label>
</div>
<div className="flex justify-end mt-2">
@@ -134,7 +138,7 @@ const Webhook = () => {
handleSaveClick();
}}
>
{t('save')}
{t("common.save")}
</Button>
</div>
</div>