diff --git a/src/app/[locale]/(protected)/dashboard/settings/page.tsx b/src/app/[locale]/(protected)/dashboard/settings/page.tsx
index 2a2ce5423..3dd6516f8 100644
--- a/src/app/[locale]/(protected)/dashboard/settings/page.tsx
+++ b/src/app/[locale]/(protected)/dashboard/settings/page.tsx
@@ -1,4 +1,5 @@
import { redirect } from "next/navigation";
+import { getTranslations } from "next-intl/server";
import { getCurrentUser } from "@/lib/session";
import { constructMetadata } from "@/lib/utils";
@@ -8,20 +9,21 @@ import { UserNameForm } from "@/components/forms/user-name-form";
import { UserRoleForm } from "@/components/forms/user-role-form";
export const metadata = constructMetadata({
- title: "Settings – FFlow Next",
+ title: "Settings – FFlow Next",
description: "Configure your account and website settings.",
});
export default async function SettingsPage() {
const user = await getCurrentUser();
+ const t = await getTranslations("Settings");
if (!user?.id) redirect("/login");
return (
<>
diff --git a/src/components/dashboard/delete-account.tsx b/src/components/dashboard/delete-account.tsx
index 5619461ac..333821430 100644
--- a/src/components/dashboard/delete-account.tsx
+++ b/src/components/dashboard/delete-account.tsx
@@ -5,8 +5,10 @@ import { Button } from "@/components/ui/button";
import { SectionColumns } from "@/components/dashboard/section-columns";
import { useDeleteAccountModal } from "@/components/modals/delete-account-modal";
import { Icons } from "@/components/shared/icons";
+import { useTranslations } from 'next-intl';
export function DeleteAccountSection() {
+ const t = useTranslations('DeleteAccountSection');
const { setShowDeleteAccountModal, DeleteAccountModal } =
useDeleteAccountModal();
@@ -16,27 +18,28 @@ export function DeleteAccountSection() {
<>
-
Are you sure ?
+
{t('areYouSure')}
{userPaidPlan ? (
- Active Subscription
+ {t('activeSubscription')}
) : null}
- Permanently delete your {siteConfig.name} account
- {userPaidPlan ? " and your subscription" : ""}. This action cannot
- be undone - please proceed with caution.
+ {t('deleteWarning', {
+ siteName: siteConfig.name,
+ subscription: userPaidPlan ? t(' and your subscription') : ''
+ })}
@@ -46,7 +49,7 @@ export function DeleteAccountSection() {
onClick={() => setShowDeleteAccountModal(true)}
>
- Delete Account
+ {t('deleteButton')}
diff --git a/src/components/forms/user-name-form.tsx b/src/components/forms/user-name-form.tsx
index 3cfd7df91..81d223d45 100644
--- a/src/components/forms/user-name-form.tsx
+++ b/src/components/forms/user-name-form.tsx
@@ -7,6 +7,7 @@ import { User } from "@/types";
import { useSession } from "next-auth/react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
+import { useTranslations } from 'next-intl'; // 导入 useTranslations 钩子
import { userNameSchema } from "@/lib/validations/user";
import { Button } from "@/components/ui/button";
@@ -20,6 +21,7 @@ interface UserNameFormProps {
}
export function UserNameForm({ user }: UserNameFormProps) {
+ const t = useTranslations('UserNameForm'); // 获取翻译函数
const { update } = useSession();
const [updated, setUpdated] = useState(false);
const [isPending, startTransition] = useTransition();
@@ -45,13 +47,13 @@ export function UserNameForm({ user }: UserNameFormProps) {
const { status } = await updateUserNameWithId(data);
if (status !== "success") {
- toast.error("Something went wrong.", {
- description: "Your name was not updated. Please try again.",
+ toast.error(t('errorTitle'), {
+ description: t('errorDescription'),
});
} else {
await update();
setUpdated(false);
- toast.success("Your name has been updated.");
+ toast.success(t('successDescription'));
}
});
});
@@ -59,12 +61,12 @@ export function UserNameForm({ user }: UserNameFormProps) {
return (
diff --git a/src/components/forms/user-role-form.tsx b/src/components/forms/user-role-form.tsx
index b1121c6a1..b1860b425 100644
--- a/src/components/forms/user-role-form.tsx
+++ b/src/components/forms/user-role-form.tsx
@@ -8,6 +8,7 @@ import { useSession } from "next-auth/react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
+import { useTranslations } from 'next-intl'; // 导入 useTranslations 钩子
import { userRoleSchema } from "@/lib/validations/user";
import { Button } from "@/components/ui/button";
@@ -34,6 +35,7 @@ interface UserNameFormProps {
}
export function UserRoleForm({ user }: UserNameFormProps) {
+ const t = useTranslations('UserRoleForm'); // 获取翻译函数
const { update } = useSession();
const [updated, setUpdated] = useState(false);
const [isPending, startTransition] = useTransition();
@@ -54,13 +56,13 @@ export function UserRoleForm({ user }: UserNameFormProps) {
const { status } = await updateUserRoleWithId(data);
if (status !== "success") {
- toast.error("Something went wrong.", {
- description: "Your role was not updated. Please try again.",
+ toast.error(t('errorTitle'), {
+ description: t('errorDescription'),
});
} else {
await update();
setUpdated(false);
- toast.success("Your role has been updated.");
+ toast.success(t('successDescription'));
}
});
};
@@ -69,8 +71,8 @@ export function UserRoleForm({ user }: UserNameFormProps) {