Revert "feat(i18n): update zh-Hans translation"

This commit is contained in:
Mauricio Siu
2025-03-15 22:08:49 -06:00
committed by GitHub
parent 5cd743eb10
commit c2e05e86d9
81 changed files with 1268 additions and 1765 deletions
@@ -26,7 +26,6 @@ import { authClient } from "@/lib/auth-client";
import { api } from "@/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
import { Fingerprint, QrCode } from "lucide-react";
import { useTranslation } from "next-i18next";
import QRCode from "qrcode";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
@@ -56,7 +55,6 @@ type PinForm = z.infer<typeof PinSchema>;
export const Enable2FA = () => {
const utils = api.useUtils();
const { t } = useTranslation();
const [data, setData] = useState<TwoFactorSetupData | null>(null);
const [backupCodes, setBackupCodes] = useState<string[]>([]);
const [isDialogOpen, setIsDialogOpen] = useState(false);
@@ -88,15 +86,13 @@ export const Enable2FA = () => {
});
setStep("verify");
toast.success(t("settings.2fa.scanQrCode"));
toast.success("Scan the QR code with your authenticator app");
} else {
throw new Error("No TOTP URI received from server");
}
} catch (error) {
toast.error(
error instanceof Error
? error.message
: t("settings.2fa.errorSettingUp"),
error instanceof Error ? error.message : "Error setting up 2FA",
);
passwordForm.setError("password", {
message:
@@ -116,9 +112,9 @@ export const Enable2FA = () => {
if (result.error) {
if (result.error.code === "INVALID_TWO_FACTOR_AUTHENTICATION") {
pinForm.setError("pin", {
message: t("settings.2fa.invalidCode"),
message: "Invalid code. Please try again.",
});
toast.error(t("settings.2fa.invalidVerificationCode"));
toast.error("Invalid verification code");
return;
}
@@ -129,14 +125,14 @@ export const Enable2FA = () => {
throw new Error("No response received from server");
}
toast.success(t("settings.2fa.success"));
toast.success("2FA configured successfully");
utils.user.get.invalidate();
setIsDialogOpen(false);
} catch (error) {
if (error instanceof Error) {
const errorMessage =
error.message === "Failed to fetch"
? t("settings.2fa.connectionError")
? "Connection error. Please check your internet connection."
: error.message;
pinForm.setError("pin", {
@@ -145,9 +141,9 @@ export const Enable2FA = () => {
toast.error(errorMessage);
} else {
pinForm.setError("pin", {
message: t("settings.2fa.errorVerifyingCode"),
message: "Error verifying code",
});
toast.error(t("settings.2fa.errorVerifying2faCode"));
toast.error("Error verifying 2FA code");
}
}
};
@@ -181,16 +177,16 @@ export const Enable2FA = () => {
<DialogTrigger asChild>
<Button variant="ghost">
<Fingerprint className="size-4 text-muted-foreground" />
{t("settings.2fa.enable2fa")}
Enable 2FA
</Button>
</DialogTrigger>
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-xl">
<DialogHeader>
<DialogTitle>{t("settings.2fa.title")}</DialogTitle>
<DialogTitle>2FA Setup</DialogTitle>
<DialogDescription>
{step === "password"
? t("settings.2fa.enterPassword")
: t("settings.2fa.scanQrCodeAndVerify")}
? "Enter your password to begin 2FA setup"
: "Scan the QR code and verify with your authenticator app"}
</DialogDescription>
</DialogHeader>
@@ -206,16 +202,16 @@ export const Enable2FA = () => {
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>{t("settings.2fa.password")}</FormLabel>
<FormLabel>Password</FormLabel>
<FormControl>
<Input
type="password"
placeholder={t("settings.2fa.enterPasswordPlaceholder")}
placeholder="Enter your password"
{...field}
/>
</FormControl>
<FormDescription>
{t("settings.2fa.enterPasswordDescription")}
Enter your password to enable 2FA
</FormDescription>
<FormMessage />
</FormItem>
@@ -226,7 +222,7 @@ export const Enable2FA = () => {
className="w-full"
isLoading={isPasswordLoading}
>
{t("settings.2fa.continue")}
Continue
</Button>
</form>
</Form>
@@ -243,16 +239,16 @@ export const Enable2FA = () => {
<div className="flex flex-col items-center gap-4 p-6 border rounded-lg">
<QrCode className="size-5 text-muted-foreground" />
<span className="text-sm font-medium">
{t("settings.2fa.scanQrCode")}
Scan this QR code with your authenticator app
</span>
<img
src={data.qrCodeUrl}
alt={t("settings.2fa.qrCodeAlt")}
alt="2FA QR Code"
className="rounded-lg w-48 h-48"
/>
<div className="flex flex-col gap-2 text-center">
<span className="text-sm text-muted-foreground">
{t("settings.2fa.cantScanQrCode")}
Can't scan the QR code?
</span>
<span className="text-xs font-mono bg-muted p-2 rounded">
{data.secret}
@@ -262,9 +258,7 @@ export const Enable2FA = () => {
{backupCodes && backupCodes.length > 0 && (
<div className="w-full space-y-3 border rounded-lg p-4">
<h4 className="font-medium">
{t("settings.2fa.backupCodes")}
</h4>
<h4 className="font-medium">Backup Codes</h4>
<div className="grid grid-cols-2 gap-2">
{backupCodes.map((code, index) => (
<code
@@ -276,7 +270,9 @@ export const Enable2FA = () => {
))}
</div>
<p className="text-sm text-muted-foreground">
{t("settings.2fa.saveBackupCodes")}
Save these backup codes in a secure place. You can use
them to access your account if you lose access to your
authenticator device.
</p>
</div>
)}
@@ -293,7 +289,7 @@ export const Enable2FA = () => {
name="pin"
render={({ field }) => (
<FormItem className="flex flex-col justify-center items-center">
<FormLabel>{t("settings.2fa.verificationCode")}</FormLabel>
<FormLabel>Verification Code</FormLabel>
<FormControl>
<InputOTP maxLength={6} {...field}>
<InputOTPGroup>
@@ -307,7 +303,7 @@ export const Enable2FA = () => {
</InputOTP>
</FormControl>
<FormDescription>
{t("settings.2fa.enterVerificationCode")}
Enter the 6-digit code from your authenticator app
</FormDescription>
<FormMessage />
</FormItem>
@@ -319,7 +315,7 @@ export const Enable2FA = () => {
className="w-full"
isLoading={isPasswordLoading}
>
{t("settings.2fa.enable2fa")}
Enable 2FA
</Button>
</form>
</Form>
@@ -62,7 +62,7 @@ export const ProfileForm = () => {
isError,
error,
} = api.user.update.useMutation();
const { t } = useTranslation();
const { t } = useTranslation("settings");
const [gravatarHash, setGravatarHash] = useState<string | null>(null);
const availableAvatars = useMemo(() => {
@@ -170,9 +170,7 @@ export const ProfileForm = () => {
name="currentPassword"
render={({ field }) => (
<FormItem>
<FormLabel>
{t("settings.profile.oldPassword")}
</FormLabel>
<FormLabel>Current Password</FormLabel>
<FormControl>
<Input
type="password"
@@ -191,7 +189,7 @@ export const ProfileForm = () => {
render={({ field }) => (
<FormItem>
<FormLabel>
{t("settings.profile.newPassword")}
{t("settings.profile.password")}
</FormLabel>
<FormControl>
<Input