fix(i18n): 补充页面缺失的中英文翻译并修复登录重定向循环
- 补充 login/signup/dictionary/srt-player/alphabet 页面的翻译 - 修复登录页面邮箱登录时 password 参数错误 - 修复登录/注册页面的无限重定向循环问题 - 调整登录/注册卡片宽度为 w-96
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"alphabet": {
|
||||
"chooseCharacters": "Please select the characters you want to learn",
|
||||
"chooseAlphabetHint": "Select an alphabet to start learning",
|
||||
"japanese": "Japanese Kana",
|
||||
"english": "English Alphabet",
|
||||
"uyghur": "Uyghur Alphabet",
|
||||
@@ -14,7 +15,11 @@
|
||||
"roman": "Romanization",
|
||||
"letter": "Letter",
|
||||
"random": "Random Mode",
|
||||
"randomNext": "Random Next"
|
||||
"randomNext": "Random Next",
|
||||
"previousLetter": "Previous letter",
|
||||
"nextLetter": "Next letter",
|
||||
"keyboardHint": "Use left/right arrow keys or space for random, ESC to go back",
|
||||
"swipeHint": "Use left/right arrow keys or swipe to navigate, ESC to go back"
|
||||
},
|
||||
"folders": {
|
||||
"title": "Folders",
|
||||
@@ -107,7 +112,8 @@
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
"title": "Authentication",
|
||||
"title": "Sign In",
|
||||
"signUpTitle": "Sign Up",
|
||||
"signIn": "Sign In",
|
||||
"signUp": "Sign Up",
|
||||
"email": "Email",
|
||||
@@ -133,7 +139,18 @@
|
||||
"identifierRequired": "Please enter your email or username",
|
||||
"passwordRequired": "Please enter your password",
|
||||
"confirmPasswordRequired": "Please confirm your password",
|
||||
"loading": "Loading..."
|
||||
"loading": "Loading...",
|
||||
"confirm": "Confirm",
|
||||
"noAccountLink": "Don't have an account? Sign up",
|
||||
"hasAccountLink": "Already have an account? Sign in",
|
||||
"usernamePlaceholder": "Username",
|
||||
"emailPlaceholder": "Email address",
|
||||
"passwordPlaceholder": "Password",
|
||||
"usernameOrEmailPlaceholder": "Username or email",
|
||||
"loginFailed": "Login failed",
|
||||
"signUpFailed": "Sign up failed",
|
||||
"fillAllFields": "Please fill in all fields",
|
||||
"enterCredentials": "Please enter username and password"
|
||||
},
|
||||
"memorize": {
|
||||
"folder_selector": {
|
||||
@@ -187,11 +204,17 @@
|
||||
"uploaded": "Uploaded",
|
||||
"notUploaded": "Not Uploaded",
|
||||
"upload": "Upload",
|
||||
"uploadVideoButton": "Upload Video",
|
||||
"uploadSubtitleButton": "Upload Subtitle",
|
||||
"subtitleUploaded": "Subtitle Uploaded ({count} entries)",
|
||||
"subtitleNotUploaded": "Subtitle Not Uploaded",
|
||||
"autoPauseStatus": "Auto Pause: {enabled}",
|
||||
"on": "On",
|
||||
"off": "Off",
|
||||
"videoUploadFailed": "Video upload failed",
|
||||
"subtitleUploadFailed": "Subtitle upload failed"
|
||||
"subtitleUploadFailed": "Subtitle upload failed",
|
||||
"subtitleLoadSuccess": "Subtitle loaded successfully",
|
||||
"subtitleLoadFailed": "Subtitle load failed"
|
||||
},
|
||||
"text_speaker": {
|
||||
"generateIPA": "Generate IPA",
|
||||
@@ -256,7 +279,9 @@
|
||||
"pleaseLogin": "Please log in first",
|
||||
"pleaseCreateFolder": "Please create a folder first",
|
||||
"savedToFolder": "Saved to folder: {folderName}",
|
||||
"saveFailed": "Save failed, please try again later"
|
||||
"saveFailed": "Save failed, please try again later",
|
||||
"definition": "Definition",
|
||||
"example": "Example"
|
||||
},
|
||||
"explore": {
|
||||
"title": "Explore",
|
||||
@@ -291,6 +316,7 @@
|
||||
"displayName": "Display Name",
|
||||
"notSet": "Not Set",
|
||||
"memberSince": "Member Since",
|
||||
"logout": "Logout",
|
||||
"folders": {
|
||||
"title": "Folders",
|
||||
"noFolders": "No folders yet",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"alphabet": {
|
||||
"chooseCharacters": "请选择您想学习的字符",
|
||||
"chooseAlphabetHint": "选择一种语言的字母表开始学习",
|
||||
"japanese": "日语假名",
|
||||
"english": "英文字母",
|
||||
"uyghur": "维吾尔字母",
|
||||
@@ -14,7 +15,11 @@
|
||||
"roman": "罗马音",
|
||||
"letter": "字母",
|
||||
"random": "随机模式",
|
||||
"randomNext": "随机下一个"
|
||||
"randomNext": "随机下一个",
|
||||
"previousLetter": "上一个字母",
|
||||
"nextLetter": "下一个字母",
|
||||
"keyboardHint": "使用左右箭头键或空格键随机切换,ESC键返回",
|
||||
"swipeHint": "使用左右箭头键或滑动切换字母"
|
||||
},
|
||||
"folders": {
|
||||
"title": "文件夹",
|
||||
@@ -108,6 +113,7 @@
|
||||
},
|
||||
"auth": {
|
||||
"title": "登录",
|
||||
"signUpTitle": "注册",
|
||||
"signIn": "登录",
|
||||
"signUp": "注册",
|
||||
"email": "邮箱",
|
||||
@@ -133,7 +139,18 @@
|
||||
"identifierRequired": "请输入邮箱或用户名",
|
||||
"passwordRequired": "请输入密码",
|
||||
"confirmPasswordRequired": "请确认密码",
|
||||
"loading": "加载中..."
|
||||
"loading": "加载中...",
|
||||
"confirm": "确认",
|
||||
"noAccountLink": "没有账号?去注册",
|
||||
"hasAccountLink": "已有账号?去登录",
|
||||
"usernamePlaceholder": "用户名",
|
||||
"emailPlaceholder": "邮箱地址",
|
||||
"passwordPlaceholder": "密码",
|
||||
"usernameOrEmailPlaceholder": "用户名或邮箱地址",
|
||||
"loginFailed": "登录失败",
|
||||
"signUpFailed": "注册失败",
|
||||
"fillAllFields": "请填写所有字段",
|
||||
"enterCredentials": "请输入用户名和密码"
|
||||
},
|
||||
"memorize": {
|
||||
"folder_selector": {
|
||||
@@ -187,11 +204,17 @@
|
||||
"subtitleFile": "字幕文件",
|
||||
"uploaded": "已上传",
|
||||
"notUploaded": "未上传",
|
||||
"uploadVideoButton": "上传视频",
|
||||
"uploadSubtitleButton": "上传字幕",
|
||||
"subtitleUploaded": "字幕已上传 ({count} 条)",
|
||||
"subtitleNotUploaded": "字幕未上传",
|
||||
"autoPauseStatus": "自动暂停: {enabled}",
|
||||
"on": "开",
|
||||
"off": "关",
|
||||
"videoUploadFailed": "视频上传失败",
|
||||
"subtitleUploadFailed": "字幕上传失败"
|
||||
"subtitleUploadFailed": "字幕上传失败",
|
||||
"subtitleLoadSuccess": "字幕加载成功",
|
||||
"subtitleLoadFailed": "字幕加载失败"
|
||||
},
|
||||
"text_speaker": {
|
||||
"generateIPA": "生成IPA",
|
||||
@@ -256,7 +279,9 @@
|
||||
"pleaseLogin": "请先登录",
|
||||
"pleaseCreateFolder": "请先创建文件夹",
|
||||
"savedToFolder": "已保存到文件夹:{folderName}",
|
||||
"saveFailed": "保存失败,请稍后重试"
|
||||
"saveFailed": "保存失败,请稍后重试",
|
||||
"definition": "释义",
|
||||
"example": "例句"
|
||||
},
|
||||
"explore": {
|
||||
"title": "探索",
|
||||
@@ -272,14 +297,6 @@
|
||||
"sortByFavorites": "按收藏数排序",
|
||||
"sortByFavoritesActive": "取消按收藏数排序"
|
||||
},
|
||||
"favorites": {
|
||||
"title": "收藏",
|
||||
"subtitle": "我收藏的文件夹",
|
||||
"loading": "加载中...",
|
||||
"noFavorites": "还没有收藏",
|
||||
"folderInfo": "{userName} • {totalPairs} 个文本对",
|
||||
"unknownUser": "未知用户"
|
||||
},
|
||||
"favorites": {
|
||||
"title": "我的收藏",
|
||||
"subtitle": "收藏的公开文件夹",
|
||||
@@ -299,6 +316,7 @@
|
||||
"displayName": "显示名称",
|
||||
"notSet": "未设置",
|
||||
"memberSince": "注册时间",
|
||||
"logout": "登出",
|
||||
"folders": {
|
||||
"title": "文件夹",
|
||||
"noFolders": "还没有文件夹",
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import Link from "next/link";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardBody } from "@/design-system/base/card";
|
||||
import { Input } from "@/design-system/base/input";
|
||||
import { PrimaryButton } from "@/design-system/base/button";
|
||||
import { VStack } from "@/design-system/layout/stack";
|
||||
|
||||
export default function LoginPage() {
|
||||
const t = useTranslations("auth");
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -19,18 +20,18 @@ export default function LoginPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const redirectTo = searchParams.get("redirect");
|
||||
|
||||
const session = authClient.useSession().data;
|
||||
const { data: session, isPending } = authClient.useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
router.push(redirectTo ?? "/profile");
|
||||
if (!isPending && session?.user?.username && !redirectTo) {
|
||||
router.push("/folders");
|
||||
}
|
||||
}, [session, router, redirectTo]);
|
||||
}, [session, isPending, router, redirectTo]);
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (!username || !password) {
|
||||
toast.error("请输入用户名和密码");
|
||||
toast.error(t("enterCredentials"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ export default function LoginPage() {
|
||||
if (username.includes("@")) {
|
||||
await authClient.signIn.email({
|
||||
email: username,
|
||||
password: username
|
||||
password: password,
|
||||
});
|
||||
} else {
|
||||
await authClient.signIn.username({
|
||||
@@ -47,9 +48,9 @@ export default function LoginPage() {
|
||||
password: password,
|
||||
});
|
||||
}
|
||||
router.push(redirectTo ?? "/profile");
|
||||
router.push(redirectTo ?? "/folders");
|
||||
} catch (error) {
|
||||
toast.error("登录失败");
|
||||
toast.error(t("loginFailed"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -57,21 +58,21 @@ export default function LoginPage() {
|
||||
|
||||
return (
|
||||
<div className="flex justify-center items-center min-h-screen">
|
||||
<Card className="w-80">
|
||||
<Card className="w-96">
|
||||
<CardBody>
|
||||
<VStack gap={4} align="center" justify="center">
|
||||
<h1 className="text-3xl font-bold text-center w-full">登录</h1>
|
||||
<h1 className="text-3xl font-bold text-center w-full">{t("title")}</h1>
|
||||
|
||||
<VStack gap={0} align="center" justify="center" className="w-full">
|
||||
<Input
|
||||
placeholder="用户名或邮箱地址"
|
||||
placeholder={t("usernameOrEmailPlaceholder")}
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
|
||||
<Input
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
placeholder={t("passwordPlaceholder")}
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
@@ -82,14 +83,14 @@ export default function LoginPage() {
|
||||
loading={loading}
|
||||
fullWidth
|
||||
>
|
||||
确认
|
||||
{t("confirm")}
|
||||
</PrimaryButton>
|
||||
|
||||
<Link
|
||||
href={"/signup" + (redirectTo ? `?redirect=${redirectTo}` : "")}
|
||||
className="text-center text-primary-500 hover:underline"
|
||||
>
|
||||
没有账号?去注册
|
||||
{t("noAccountLink")}
|
||||
</Link>
|
||||
</VStack>
|
||||
</CardBody>
|
||||
|
||||
@@ -5,9 +5,9 @@ import { headers } from "next/headers";
|
||||
export default async function ProfilePage() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
|
||||
if (!session) {
|
||||
if (!session?.user?.id) {
|
||||
redirect("/login?redirect=/profile");
|
||||
}
|
||||
|
||||
redirect(`/users/${session.user.username}`);
|
||||
redirect(session.user.username ? `/users/${session.user.username}` : "/folders");
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ import Link from "next/link";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardBody } from "@/design-system/base/card";
|
||||
import { Input } from "@/design-system/base/input";
|
||||
import { PrimaryButton } from "@/design-system/base/button";
|
||||
import { VStack } from "@/design-system/layout/stack";
|
||||
|
||||
export default function SignUpPage() {
|
||||
const t = useTranslations("auth");
|
||||
const [username, setUsername] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
@@ -20,18 +22,18 @@ export default function SignUpPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const redirectTo = searchParams.get("redirect");
|
||||
|
||||
const session = authClient.useSession().data;
|
||||
const { data: session, isPending } = authClient.useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
router.push(redirectTo ?? "/profile");
|
||||
if (!isPending && session?.user?.username && !redirectTo) {
|
||||
router.push("/folders");
|
||||
}
|
||||
}, [session, router, redirectTo]);
|
||||
}, [session, isPending, router, redirectTo]);
|
||||
|
||||
const handleSignUp = async () => {
|
||||
if (!username || !email || !password) {
|
||||
toast.error("请填写所有字段");
|
||||
toast.error(t("fillAllFields"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,9 +45,9 @@ export default function SignUpPage() {
|
||||
username: username,
|
||||
password: password,
|
||||
});
|
||||
router.push(redirectTo ?? "/profile");
|
||||
router.push(redirectTo ?? "/folders");
|
||||
} catch (error) {
|
||||
toast.error("注册失败");
|
||||
toast.error(t("signUpFailed"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -53,28 +55,28 @@ export default function SignUpPage() {
|
||||
|
||||
return (
|
||||
<div className="flex justify-center items-center min-h-screen">
|
||||
<Card className="w-80">
|
||||
<Card className="w-96">
|
||||
<CardBody>
|
||||
<VStack gap={4} align="center" justify="center">
|
||||
<h1 className="text-3xl font-bold text-center w-full">注册</h1>
|
||||
<h1 className="text-3xl font-bold text-center w-full">{t("signUpTitle")}</h1>
|
||||
|
||||
<VStack gap={0} align="center" justify="center" className="w-full">
|
||||
<Input
|
||||
placeholder="用户名"
|
||||
placeholder={t("usernamePlaceholder")}
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
|
||||
<Input
|
||||
type="email"
|
||||
placeholder="邮箱地址"
|
||||
placeholder={t("emailPlaceholder")}
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
|
||||
<Input
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
placeholder={t("passwordPlaceholder")}
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
@@ -85,14 +87,14 @@ export default function SignUpPage() {
|
||||
loading={loading}
|
||||
fullWidth
|
||||
>
|
||||
确认
|
||||
{t("confirm")}
|
||||
</PrimaryButton>
|
||||
|
||||
<Link
|
||||
href={"/login" + (redirectTo ? `?redirect=${redirectTo}` : "")}
|
||||
className="text-center text-primary-500 hover:underline"
|
||||
>
|
||||
已有账号?去登录
|
||||
{t("hasAccountLink")}
|
||||
</Link>
|
||||
</VStack>
|
||||
</CardBody>
|
||||
|
||||
@@ -42,7 +42,7 @@ export default async function UserPage({ params }: UserPageProps) {
|
||||
<div className="bg-white rounded-lg shadow-md p-6 mb-6">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div></div>
|
||||
{isOwnProfile && <LinkButton href="/logout">登出</LinkButton>}
|
||||
{isOwnProfile && <LinkButton href="/logout">{t("logout")}</LinkButton>}
|
||||
</div>
|
||||
<div className="flex items-center space-x-6">
|
||||
{/* Avatar */}
|
||||
|
||||
@@ -54,8 +54,8 @@ export default function Alphabet() {
|
||||
{t("chooseCharacters")}
|
||||
</h1>
|
||||
{/* 副标题说明 */}
|
||||
<p className="text-gray-600 mb-8 text-lg">
|
||||
选择一种语言的字母表开始学习
|
||||
<p className="text-lg text-gray-600 text-center">
|
||||
{t("chooseAlphabetHint")}
|
||||
</p>
|
||||
|
||||
{/* 语言选择按钮网格 */}
|
||||
|
||||
@@ -133,10 +133,11 @@ export function DictionaryClient({ initialFolders }: DictionaryClientProps) {
|
||||
placeholder={t("searchPlaceholder")}
|
||||
variant="search"
|
||||
required
|
||||
containerClassName="flex-1"
|
||||
/>
|
||||
<LightButton
|
||||
type="submit"
|
||||
className="px-6 py-3 whitespace-nowrap text-center sm:min-w-30"
|
||||
className="h-10 px-6 rounded-full whitespace-nowrap"
|
||||
loading={isSearching}
|
||||
>
|
||||
{t("search")}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { TSharedEntry } from "@/shared/dictionary-type";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
interface DictionaryEntryProps {
|
||||
entry: TSharedEntry;
|
||||
}
|
||||
|
||||
export function DictionaryEntry({ entry }: DictionaryEntryProps) {
|
||||
const t = useTranslations("dictionary");
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* 音标和词性 */}
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
{entry.ipa && (
|
||||
<span className="text-gray-600 text-lg">
|
||||
@@ -21,19 +23,17 @@ export function DictionaryEntry({ entry }: DictionaryEntryProps) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 释义 */}
|
||||
<div className="mb-3">
|
||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
||||
释义
|
||||
{t("definition")}
|
||||
</h3>
|
||||
<p className="text-gray-800">{entry.definition}</p>
|
||||
</div>
|
||||
|
||||
{/* 例句 */}
|
||||
{entry.example && (
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
||||
例句
|
||||
{t("example")}
|
||||
</h3>
|
||||
<p className="text-gray-700 pl-4 border-l-4 border-[#35786f]">
|
||||
{entry.example}
|
||||
|
||||
@@ -127,21 +127,21 @@ export default function SrtPlayerPage() {
|
||||
<div className="border-gray-200 border-2 flex items p-2 justify-between items-center rounded gap-8">
|
||||
<div className="flex items-center flex-col">
|
||||
<Video size={16} />
|
||||
<span className="text-sm">视频文件</span>
|
||||
<span className="text-sm">{srtT("videoFile")}</span>
|
||||
</div>
|
||||
<LightButton onClick={handleVideoUpload} disabled={!!videoUrl}>
|
||||
{videoUrl ? '已上传' : '上传视频'}
|
||||
{videoUrl ? srtT("uploaded") : srtT("uploadVideoButton")}
|
||||
</LightButton>
|
||||
</div>
|
||||
<div className="border-gray-200 border-2 flex items p-2 justify-between items-center rounded gap-8">
|
||||
<div className="flex items-center flex-col">
|
||||
<FileText size={16} />
|
||||
<span className="text-sm">
|
||||
{subtitleData.length > 0 ? `字幕已上传 (${subtitleData.length} 条)` : "字幕未上传"}
|
||||
{subtitleData.length > 0 ? srtT("subtitleUploaded", { count: subtitleData.length }) : srtT("subtitleNotUploaded")}
|
||||
</span>
|
||||
</div>
|
||||
<LightButton onClick={handleSubtitleUpload} disabled={!!subtitleUrl}>
|
||||
{subtitleUrl ? '已上传' : '上传字幕'}
|
||||
{subtitleUrl ? srtT("uploaded") : srtT("uploadSubtitleButton")}
|
||||
</LightButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user