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

@@ -20,7 +20,7 @@ import { useTranslation } from "react-i18next";
import { z } from "zod";
const formSchema = z.object({
email: z.string().email("setting.account.email.valid.message"),
email: z.string().email("settings.account.email.errmsg.invalid"),
});
const Account = () => {
@@ -45,8 +45,8 @@ const Account = () => {
getPb().authStore.clear();
toast({
title: t("setting.account.email.change.succeed"),
description: t("setting.account.log.back.in"),
title: t("settings.account.email.changed.message"),
description: t("settings.account.relogin.message"),
});
setTimeout(() => {
navigate("/login");
@@ -54,7 +54,7 @@ const Account = () => {
} catch (e) {
const message = getErrMessage(e);
toast({
title: t("setting.account.email.change.failed"),
title: t("settings.account.email.failed.message"),
description: message,
variant: "destructive",
});
@@ -74,10 +74,10 @@ const Account = () => {
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>{t('email')}</FormLabel>
<FormLabel>{t("settings.account.email.label")}</FormLabel>
<FormControl>
<Input
placeholder={t('setting.email.placeholder')}
placeholder={t("settings.account.email.placeholder")}
{...field}
type="email"
onChange={(e) => {
@@ -94,10 +94,10 @@ const Account = () => {
<div className="flex justify-end">
{changed ? (
<Button type="submit">{t('setting.submit')}</Button>
<Button type="submit">{t("common.update")}</Button>
) : (
<Button type="submit" disabled variant={"secondary"}>
{t('setting.submit')}
{t("common.update")}
</Button>
)}
</div>

View File

@@ -20,7 +20,9 @@ const Notify = () => {
<div className="border rounded-sm p-5 shadow-lg">
<Accordion type={"multiple"} className="dark:text-stone-200">
<AccordionItem value="item-1" className="dark:border-stone-200">
<AccordionTrigger>{t('template')}</AccordionTrigger>
<AccordionTrigger>
{t("settings.notification.template.label")}
</AccordionTrigger>
<AccordionContent>
<NotifyTemplate />
</AccordionContent>
@@ -30,21 +32,21 @@ const Notify = () => {
<div className="border rounded-md p-5 mt-7 shadow-lg">
<Accordion type={"single"} className="dark:text-stone-200">
<AccordionItem value="item-2" className="dark:border-stone-200">
<AccordionTrigger>{t('ding.talk')}</AccordionTrigger>
<AccordionTrigger>{t("common.provider.dingtalk")}</AccordionTrigger>
<AccordionContent>
<DingTalk />
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-4" className="dark:border-stone-200">
<AccordionTrigger>{t('telegram')}</AccordionTrigger>
<AccordionTrigger>{t("common.provider.telegram")}</AccordionTrigger>
<AccordionContent>
<Telegram />
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-5" className="dark:border-stone-200">
<AccordionTrigger>{t('webhook')}</AccordionTrigger>
<AccordionTrigger>{t("common.provider.webhook")}</AccordionTrigger>
<AccordionContent>
<Webhook />
</AccordionContent>

View File

@@ -21,17 +21,17 @@ import { z } from "zod";
const formSchema = z
.object({
oldPassword: z.string().min(10, {
message: "setting.password.length.message",
message: "settings.password.password.errmsg.length",
}),
newPassword: z.string().min(10, {
message: "setting.password.length.message",
message: "settings.password.password.errmsg.length",
}),
confirmPassword: z.string().min(10, {
message: "setting.password.length.message",
message: "settings.password.password.errmsg.length",
}),
})
.refine((data) => data.newPassword === data.confirmPassword, {
message: "setting.password.not.match",
message: "settings.password.password.errmsg.not_matched",
path: ["confirmPassword"],
});
@@ -68,8 +68,8 @@ const Password = () => {
getPb().authStore.clear();
toast({
title: t('setting.password.change.succeed'),
description: t("setting.account.log.back.in"),
title: t("settings.password.changed.message"),
description: t("settings.account.relogin.message"),
});
setTimeout(() => {
navigate("/login");
@@ -77,7 +77,7 @@ const Password = () => {
} catch (e) {
const message = getErrMessage(e);
toast({
title: t('setting.password.change.failed'),
title: t("settings.password.failed.message"),
description: message,
variant: "destructive",
});
@@ -97,9 +97,17 @@ const Password = () => {
name="oldPassword"
render={({ field }) => (
<FormItem>
<FormLabel>{t('setting.password.current.password')}</FormLabel>
<FormLabel>
{t("settings.password.current_password.label")}
</FormLabel>
<FormControl>
<Input placeholder={t('setting.password.current.password')} {...field} type="password" />
<Input
placeholder={t(
"settings.password.current_password.placeholder"
)}
{...field}
type="password"
/>
</FormControl>
<FormMessage />
@@ -112,10 +120,14 @@ const Password = () => {
name="newPassword"
render={({ field }) => (
<FormItem>
<FormLabel>{t('setting.password.new.password')}</FormLabel>
<FormLabel>
{t("settings.password.new_password.label")}
</FormLabel>
<FormControl>
<Input
placeholder="newPassword"
placeholder={t(
"settings.password.new_password.placeholder"
)}
{...field}
type="password"
/>
@@ -131,10 +143,14 @@ const Password = () => {
name="confirmPassword"
render={({ field }) => (
<FormItem>
<FormLabel>{t('setting.password.confirm.password')}</FormLabel>
<FormLabel>
{t("settings.password.confirm_password.label")}
</FormLabel>
<FormControl>
<Input
placeholder="confirmPassword"
placeholder={t(
"settings.password.confirm_password.placeholder"
)}
{...field}
type="password"
/>
@@ -145,7 +161,7 @@ const Password = () => {
)}
/>
<div className="flex justify-end">
<Button type="submit">{t('setting.submit')}</Button>
<Button type="submit">{t("common.update")}</Button>
</div>
</form>
</Form>

View File

@@ -35,7 +35,7 @@ const SSLProvider = () => {
const formSchema = z.object({
provider: z.enum(["letsencrypt", "zerossl"], {
message: t("setting.ca.not.empty"),
message: t("settings.ca.provider.errmsg.empty"),
}),
eabKid: z.string().optional(),
eabHmacKey: z.string().optional(),
@@ -89,12 +89,12 @@ const SSLProvider = () => {
if (values.provider === "zerossl") {
if (!values.eabKid) {
form.setError("eabKid", {
message: t("setting.ca.eab_kid_hmac_key.not.empty"),
message: t("settings.ca.eab_kid_hmac_key.errmsg.empty"),
});
}
if (!values.eabHmacKey) {
form.setError("eabHmacKey", {
message: t("setting.ca.eab_kid_hmac_key.not.empty"),
message: t("settings.ca.eab_kid_hmac_key.errmsg.empty"),
});
}
if (!values.eabKid || !values.eabHmacKey) {
@@ -120,13 +120,13 @@ const SSLProvider = () => {
try {
await update(setting);
toast({
title: t("update.succeed"),
description: t("update.succeed"),
title: t("common.update.succeeded.message"),
description: t("common.update.succeeded.message"),
});
} catch (e) {
const message = getErrMessage(e);
toast({
title: t("update.failed"),
title: t("common.update.failed.message"),
description: message,
variant: "destructive",
});
@@ -146,7 +146,7 @@ const SSLProvider = () => {
name="provider"
render={({ field }) => (
<FormItem>
<FormLabel>{t("ca")}</FormLabel>
<FormLabel>{t("common.text.ca")}</FormLabel>
<FormControl>
<RadioGroup
{...field}
@@ -202,7 +202,7 @@ const SSLProvider = () => {
<FormLabel>EAB_KID</FormLabel>
<FormControl>
<Input
placeholder={t("setting.ca.eab_kid.not.empty")}
placeholder={t("settings.ca.eab_kid.errmsg.empty")}
{...field}
type="text"
/>
@@ -221,7 +221,9 @@ const SSLProvider = () => {
<FormLabel>EAB_HMAC_KEY</FormLabel>
<FormControl>
<Input
placeholder={t("setting.ca.eab_hmac_key.not.empty")}
placeholder={t(
"settings.ca.eab_hmac_key.errmsg.empty"
)}
{...field}
type="text"
/>
@@ -238,7 +240,7 @@ const SSLProvider = () => {
/>
<div className="flex justify-end">
<Button type="submit">{t("setting.submit")}</Button>
<Button type="submit">{t("common.update")}</Button>
</div>
</form>
</Form>