Compare commits
1 Commits
main
...
3db1b3716f
| Author | SHA1 | Date | |
|---|---|---|---|
| 3db1b3716f |
@@ -4,34 +4,4 @@ node_modules
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
README.md
|
README.md
|
||||||
.next
|
.next
|
||||||
.git
|
.git
|
||||||
certificates
|
|
||||||
|
|
||||||
# testing
|
|
||||||
/coverage
|
|
||||||
test.ts
|
|
||||||
test.js
|
|
||||||
|
|
||||||
# build outputs
|
|
||||||
/out/
|
|
||||||
/build
|
|
||||||
*.tsbuildinfo
|
|
||||||
next-env.d.ts
|
|
||||||
|
|
||||||
# debug logs
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# env files
|
|
||||||
.env*
|
|
||||||
!.env.example
|
|
||||||
|
|
||||||
# misc
|
|
||||||
.DS_Store
|
|
||||||
*.pem
|
|
||||||
.vercel
|
|
||||||
build.sh
|
|
||||||
|
|
||||||
# prisma
|
|
||||||
/generated/prisma
|
|
||||||
11
.drone.yml
11
.drone.yml
@@ -19,15 +19,6 @@ steps:
|
|||||||
registry: registry.edian-studio.com
|
registry: registry.edian-studio.com
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
|
|
||||||
- name: database migrate
|
|
||||||
image: node:24-alpine
|
|
||||||
environment:
|
|
||||||
DATABASE_URL:
|
|
||||||
from_secret: database_url
|
|
||||||
commands:
|
|
||||||
- npm i --no-save prisma@7 @prisma/client@7 "@prisma/adapter-pg"
|
|
||||||
- npx prisma migrate deploy
|
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
@@ -41,7 +32,7 @@ steps:
|
|||||||
port: 22
|
port: 22
|
||||||
script:
|
script:
|
||||||
- cd ~/docker/learn-languages
|
- cd ~/docker/learn-languages
|
||||||
- docker compose up -d --pull always --force-recreate
|
- docker compose up -d
|
||||||
debug: true
|
debug: true
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
|
|||||||
15
.env.example
15
.env.example
@@ -1,15 +0,0 @@
|
|||||||
// LLM
|
|
||||||
ZHIPU_API_KEY=
|
|
||||||
ZHIPU_MODEL_NAME=
|
|
||||||
|
|
||||||
// Auth
|
|
||||||
BETTER_AUTH_SECRET=
|
|
||||||
BETTER_AUTH_URL=
|
|
||||||
GITHUB_CLIENT_ID=
|
|
||||||
GITHUB_CLIENT_SECRET=
|
|
||||||
|
|
||||||
// Database
|
|
||||||
DATABASE_URL=
|
|
||||||
|
|
||||||
// DashScore
|
|
||||||
DASHSCORE_API_KEY=
|
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -41,12 +41,7 @@ yarn-error.log*
|
|||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
.env
|
.env
|
||||||
!.env.example
|
|
||||||
|
|
||||||
build.sh
|
build.sh
|
||||||
|
|
||||||
test.ts
|
test.ts
|
||||||
test.js
|
|
||||||
/generated/prisma
|
|
||||||
|
|
||||||
certificates
|
|
||||||
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
|
||||||
"editor.defaultFormatter": null,
|
|
||||||
"[typescript]": {
|
|
||||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
||||||
},
|
|
||||||
"[typescriptreact]": {
|
|
||||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
125
CLAUDE.md
125
CLAUDE.md
@@ -1,125 +0,0 @@
|
|||||||
# CLAUDE.md
|
|
||||||
|
|
||||||
本文件为 Claude Code (claude.ai/code) 在此代码库中工作时提供指导。
|
|
||||||
|
|
||||||
## 项目概述
|
|
||||||
|
|
||||||
这是一个基于 Next.js 16 构建的全栈语言学习平台,提供翻译工具、文本转语音、字幕播放、字母学习和记忆功能。平台支持 8 种语言,具有完整的国际化支持。
|
|
||||||
|
|
||||||
## 开发命令
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 启动开发服务器(启用 HTTPS)
|
|
||||||
pnpm run dev
|
|
||||||
|
|
||||||
# 构建生产版本(standalone 输出模式,用于 Docker)
|
|
||||||
pnpm run build
|
|
||||||
|
|
||||||
# 启动生产服务器
|
|
||||||
pnpm run start
|
|
||||||
|
|
||||||
# 代码检查
|
|
||||||
pnpm run lint
|
|
||||||
|
|
||||||
# 数据库操作
|
|
||||||
pnpm prisma generate # 生成 Prisma client 到 src/generated/prisma
|
|
||||||
pnpm prisma db push # 推送 schema 变更到数据库
|
|
||||||
pnpm prisma studio # 打开 Prisma Studio 查看数据库
|
|
||||||
```
|
|
||||||
|
|
||||||
## 技术栈
|
|
||||||
|
|
||||||
- **Next.js 16** 使用 App Router 和 standalone 输出模式
|
|
||||||
- **React 19** 启用 React Compiler 进行优化
|
|
||||||
- **TypeScript** 严格模式和 ES2023 目标
|
|
||||||
- **Tailwind CSS v4** 样式框架
|
|
||||||
- **PostgreSQL** + **Prisma ORM**(自定义输出目录:`src/generated/prisma`)
|
|
||||||
- **better-auth** 身份验证(邮箱/密码 + OAuth)
|
|
||||||
- **next-intl** 国际化(支持:en-US, zh-CN, ja-JP, ko-KR, de-DE, fr-FR, it-IT, ug-CN)
|
|
||||||
- **edge-tts-universal** 文本转语音
|
|
||||||
- **pnpm** 包管理器
|
|
||||||
|
|
||||||
## 架构设计
|
|
||||||
|
|
||||||
### 路由结构
|
|
||||||
|
|
||||||
应用使用 Next.js App Router 和基于功能的组织方式:
|
|
||||||
|
|
||||||
```
|
|
||||||
src/app/
|
|
||||||
├── (features)/ # 功能模块(translator, alphabet, memorize, dictionary, srt-player)
|
|
||||||
│ └── [locale]/ # 国际化路由
|
|
||||||
├── auth/ # 认证页面(sign-in, sign-up)
|
|
||||||
├── folders/ # 用户学习文件夹管理
|
|
||||||
├── api/ # API 路由
|
|
||||||
└── profile/ # 用户资料页面
|
|
||||||
```
|
|
||||||
|
|
||||||
### 数据库 Schema
|
|
||||||
|
|
||||||
核心模型(见 [prisma/schema.prisma](prisma/schema.prisma)):
|
|
||||||
- **User**: 用户中心实体,包含认证信息
|
|
||||||
- **Folder**: 用户拥有的学习资料容器(级联删除 pairs)
|
|
||||||
- **Pair**: 语言对(翻译/词汇),支持 IPA,唯一约束为 (folderId, locale1, locale2, text1)
|
|
||||||
- **Session/Account**: better-auth 追踪
|
|
||||||
- **Verification**: 邮箱验证系统
|
|
||||||
|
|
||||||
### 核心模式
|
|
||||||
|
|
||||||
**Server Actions**: 数据库变更使用 `src/lib/actions/` 中的 Server Actions,配合类型安全的 Prisma 操作。
|
|
||||||
|
|
||||||
**基于功能的组件**: 每个功能在 `(features)/` 下有自己的路由组,带有 locale 前缀。
|
|
||||||
|
|
||||||
**国际化**: 所有面向用户的内容通过 next-intl 处理。消息文件在 `messages/` 目录。locale 自动检测并在路由中前缀。
|
|
||||||
|
|
||||||
**认证流程**: better-auth 使用客户端适配器 (`authClient`),通过 hooks 管理会话,受保护的路由使用条件渲染。
|
|
||||||
|
|
||||||
**LLM 集成**: 使用智谱 AI API 进行翻译和 IPA 生成。通过环境变量 `ZHIPU_API_KEY` 和 `ZHIPU_MODEL_NAME` 配置。
|
|
||||||
|
|
||||||
### 环境变量
|
|
||||||
|
|
||||||
需要在 `.env.local` 中配置:
|
|
||||||
|
|
||||||
```env
|
|
||||||
# LLM 集成
|
|
||||||
ZHIPU_API_KEY=your-api-key
|
|
||||||
ZHIPU_MODEL_NAME=your-model-name
|
|
||||||
|
|
||||||
# 认证
|
|
||||||
BETTER_AUTH_SECRET=your-secret
|
|
||||||
BETTER_AUTH_URL=http://localhost:3000
|
|
||||||
GITHUB_CLIENT_ID=your-client-id
|
|
||||||
GITHUB_CLIENT_SECRET=your-client-secret
|
|
||||||
|
|
||||||
# 数据库
|
|
||||||
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
|
|
||||||
|
|
||||||
// DashScore
|
|
||||||
DASHSCORE_API_KEY=
|
|
||||||
```
|
|
||||||
|
|
||||||
## 重要配置细节
|
|
||||||
|
|
||||||
- **Prisma client 输出**: 自定义目录 `src/generated/prisma`(不是默认的 `node_modules/.prisma`)
|
|
||||||
- **Standalone 输出**: 为 Docker 部署配置
|
|
||||||
- **React Compiler**: 在 `next.config.ts` 中启用以自动优化
|
|
||||||
- **HTTPS 开发**: 开发服务器使用 `--experimental-https` 标志
|
|
||||||
- **图片优化**: 通过 remote patterns 允许 GitHub 头像
|
|
||||||
|
|
||||||
## 代码组织
|
|
||||||
|
|
||||||
- `src/lib/actions/`: 数据库变更的 Server Actions
|
|
||||||
- `src/lib/server/`: 服务端工具(AI 集成、认证、翻译器)
|
|
||||||
- `src/lib/browser/`: 客户端工具
|
|
||||||
- `src/hooks/`: 自定义 React hooks(认证 hooks、会话管理)
|
|
||||||
- `src/i18n/`: 国际化配置
|
|
||||||
- `messages/`: 各支持语言的翻译文件
|
|
||||||
- `src/components/`: 可复用的 UI 组件(buttons, cards 等)
|
|
||||||
|
|
||||||
## 开发注意事项
|
|
||||||
|
|
||||||
- 使用 pnpm,而不是 npm 或 yarn
|
|
||||||
- schema 变更后,先运行 `pnpm prisma generate` 再运行 `pnpm prisma db push`
|
|
||||||
- 应用使用 TypeScript 严格模式 - 确保类型安全
|
|
||||||
- 所有面向用户的文本都需要国际化
|
|
||||||
- Better-auth 处理会话管理 - 使用 authClient 适配器进行认证操作
|
|
||||||
29
Dockerfile
29
Dockerfile
@@ -1,27 +1,23 @@
|
|||||||
# syntax=docker.io/docker/dockerfile:1
|
# syntax=docker.io/docker/dockerfile:1
|
||||||
|
|
||||||
FROM node:24-alpine AS base
|
FROM node:23-alpine AS base
|
||||||
|
|
||||||
# Install dependencies only when needed
|
# Install dependencies only when needed
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
RUN apk add --no-cache libc6-compat openssl
|
RUN apk add --no-cache libc6-compat
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies based on the preferred package manager
|
# Install dependencies based on the preferred package manager
|
||||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
||||||
# RUN \
|
|
||||||
# if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
|
||||||
# elif [ -f package-lock.json ]; then npm ci; \
|
|
||||||
# elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
|
||||||
# else echo "Lockfile not found." && exit 1; \
|
|
||||||
# fi
|
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||||
|
elif [ -f package-lock.json ]; then npm ci; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
||||||
else echo "Lockfile not found." && exit 1; \
|
else echo "Lockfile not found." && exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -33,17 +29,10 @@ COPY . .
|
|||||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
# RUN \
|
|
||||||
# if [ -f yarn.lock ]; then yarn run build; \
|
|
||||||
# elif [ -f package-lock.json ]; then npm run build; \
|
|
||||||
# elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
|
||||||
# else echo "Lockfile not found." && exit 1; \
|
|
||||||
# fi
|
|
||||||
|
|
||||||
RUN DATABASE_URL=postgresql://fake:fake@fake:5432/fake npx prisma@7 generate
|
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
if [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
if [ -f yarn.lock ]; then yarn run build; \
|
||||||
|
elif [ -f package-lock.json ]; then npm run build; \
|
||||||
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
||||||
else echo "Lockfile not found." && exit 1; \
|
else echo "Lockfile not found." && exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
141
LICENSE
141
LICENSE
@@ -1,5 +1,5 @@
|
|||||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 19 November 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
@@ -7,15 +7,17 @@
|
|||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU Affero General Public License is a free, copyleft license for
|
The GNU General Public License is a free, copyleft license for
|
||||||
software and other kinds of works, specifically designed to ensure
|
software and other kinds of works.
|
||||||
cooperation with the community in the case of network server software.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
our General Public Licenses are intended to guarantee your freedom to
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains free
|
||||||
software for all its users.
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
@@ -24,34 +26,44 @@ them if you wish), that you receive source code or can get it if you
|
|||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
Developers that use our General Public Licenses protect your rights
|
To protect your rights, we need to prevent others from denying you
|
||||||
with two steps: (1) assert copyright on the software, and (2) offer
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
you this License which gives you legal permission to copy, distribute
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
and/or modify the software.
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
A secondary benefit of defending all users' freedom is that
|
For example, if you distribute copies of such a program, whether
|
||||||
improvements made in alternate versions of the program, if they
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
receive widespread use, become available for other developers to
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
incorporate. Many developers of free software are heartened and
|
or can get the source code. And you must show them these terms so they
|
||||||
encouraged by the resulting cooperation. However, in the case of
|
know their rights.
|
||||||
software used on network servers, this result may fail to come about.
|
|
||||||
The GNU General Public License permits making a modified version and
|
|
||||||
letting the public access it on a server without ever releasing its
|
|
||||||
source code to the public.
|
|
||||||
|
|
||||||
The GNU Affero General Public License is designed specifically to
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
ensure that, in such cases, the modified source code becomes available
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
to the community. It requires the operator of a network server to
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
provide the source code of the modified version running there to the
|
|
||||||
users of that server. Therefore, public use of a modified version, on
|
|
||||||
a publicly accessible server, gives the public access to the source
|
|
||||||
code of the modified version.
|
|
||||||
|
|
||||||
An older license, called the Affero General Public License and
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
published by Affero, was designed to accomplish similar goals. This is
|
that there is no warranty for this free software. For both users' and
|
||||||
a different license, not a version of the Affero GPL, but Affero has
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
released a new version of the Affero GPL which permits relicensing under
|
changed, so that their problems will not be attributed erroneously to
|
||||||
this license.
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
@@ -60,7 +72,7 @@ modification follow.
|
|||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
@@ -537,45 +549,35 @@ to collect a royalty for further conveying from those to whom you convey
|
|||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, if you modify the
|
|
||||||
Program, your modified version must prominently offer all users
|
|
||||||
interacting with it remotely through a computer network (if your version
|
|
||||||
supports such interaction) an opportunity to receive the Corresponding
|
|
||||||
Source of your version by providing access to the Corresponding Source
|
|
||||||
from a network server at no charge, through some standard or customary
|
|
||||||
means of facilitating copying of software. This Corresponding Source
|
|
||||||
shall include the Corresponding Source for any work covered by version 3
|
|
||||||
of the GNU General Public License that is incorporated pursuant to the
|
|
||||||
following paragraph.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU General Public License into a single
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the work with which it is combined will remain governed by version
|
but the special requirements of the GNU Affero General Public License,
|
||||||
3 of the GNU General Public License.
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU Affero General Public License from time to time. Such new versions
|
the GNU General Public License from time to time. Such new versions will
|
||||||
will be similar in spirit to the present version, but may differ in detail to
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU Affero General
|
Program specifies that a certain numbered version of the GNU General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU Affero General Public License, you may choose any version ever published
|
GNU General Public License, you may choose any version ever published
|
||||||
by the Free Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future
|
||||||
versions of the GNU Affero General Public License can be used, that proxy's
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
@@ -633,29 +635,40 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If your software can interact with users remotely through a computer
|
If the program does terminal interaction, make it output a short
|
||||||
network, you should also make sure that it provides a way for users to
|
notice like this when it starts in an interactive mode:
|
||||||
get its source. For example, if your program is a web application, its
|
|
||||||
interface could display a "Source" link that leads users to an archive
|
<program> Copyright (C) <year> <name of author>
|
||||||
of the code. There are many ways you could offer source, and different
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
solutions will be better for different programs; see section 13 for the
|
This is free software, and you are welcome to redistribute it
|
||||||
specific requirements.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
<https://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|||||||
168
README.md
168
README.md
@@ -1,162 +1,36 @@
|
|||||||
# 多语言学习平台
|
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||||
|
|
||||||
一个基于 Next.js 构建的全功能多语言学习平台,提供翻译、发音、字幕播放、字母学习等多种语言学习工具,帮助用户更高效地掌握新语言。
|
## Getting Started
|
||||||
|
|
||||||
## ✨ 主要功能
|
First, run the development server:
|
||||||
|
|
||||||
- **智能翻译工具** - 支持多语言互译,包含国际音标(IPA)标注
|
|
||||||
- **文本语音合成** - 将文本转换为自然语音,提高发音学习效果
|
|
||||||
- **SRT字幕播放器** - 结合视频字幕学习,支持多种字幕格式
|
|
||||||
- **字母学习模块** - 针对初学者的字母和发音基础学习
|
|
||||||
- **记忆强化工具** - 通过科学记忆法巩固学习内容
|
|
||||||
- **个人学习空间** - 用户可以创建、管理和组织自己的学习资料
|
|
||||||
|
|
||||||
## 🛠 技术栈
|
|
||||||
|
|
||||||
### 前端框架
|
|
||||||
- **Next.js 16** - React 全栈框架,使用 App Router
|
|
||||||
- **React 19** - 用户界面构建
|
|
||||||
- **TypeScript** - 类型安全的 JavaScript
|
|
||||||
- **Tailwind CSS** - 实用优先的 CSS 框架
|
|
||||||
|
|
||||||
### 数据与后端
|
|
||||||
- **PostgreSQL** - 主数据库
|
|
||||||
- **Prisma** - 现代数据库工具包和 ORM
|
|
||||||
- **better-auth** - 安全的身份验证系统
|
|
||||||
|
|
||||||
### 国际化与辅助功能
|
|
||||||
- **next-intl** - 国际化解决方案
|
|
||||||
- **qwen3-tts-flash** - 通义千问语音合成
|
|
||||||
|
|
||||||
### 开发工具
|
|
||||||
- **ESLint** - 代码质量检查
|
|
||||||
- **pnpm** - 高效的包管理器
|
|
||||||
|
|
||||||
## 📁 项目结构
|
|
||||||
|
|
||||||
```
|
|
||||||
src/
|
|
||||||
├── app/ # Next.js App Router 路由
|
|
||||||
│ ├── (features)/ # 功能模块路由
|
|
||||||
│ ├── api/ # API 路由
|
|
||||||
│ └── auth/ # 认证相关页面
|
|
||||||
├── components/ # React 组件
|
|
||||||
│ ├── buttons/ # 按钮组件
|
|
||||||
│ ├── cards/ # 卡片组件
|
|
||||||
│ └── ...
|
|
||||||
├── lib/ # 工具函数和库
|
|
||||||
│ ├── actions/ # Server Actions
|
|
||||||
│ ├── browser/ # 浏览器端工具
|
|
||||||
│ └── server/ # 服务器端工具
|
|
||||||
├── hooks/ # 自定义 React Hooks
|
|
||||||
├── i18n/ # 国际化配置
|
|
||||||
└── config/ # 应用配置
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🚀 快速开始
|
|
||||||
|
|
||||||
### 环境要求
|
|
||||||
|
|
||||||
- Node.js 24
|
|
||||||
- PostgreSQL 数据库
|
|
||||||
- pnpm (推荐) 或 npm
|
|
||||||
|
|
||||||
### 本地开发
|
|
||||||
|
|
||||||
1. 克隆项目
|
|
||||||
```bash
|
|
||||||
git clone <repository-url>
|
|
||||||
cd learn-languages
|
|
||||||
```
|
|
||||||
|
|
||||||
2. 安装依赖
|
|
||||||
```bash
|
|
||||||
pnpm install
|
|
||||||
```
|
|
||||||
|
|
||||||
3. 设置环境变量
|
|
||||||
|
|
||||||
从项目提供的示例文件复制环境变量模板:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env.local
|
npm run dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
# or
|
||||||
|
pnpm dev
|
||||||
|
# or
|
||||||
|
bun dev
|
||||||
```
|
```
|
||||||
|
|
||||||
然后编辑 `.env.local` 文件,配置所有必要的环境变量:
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
```env
|
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||||
// LLM
|
|
||||||
ZHIPU_API_KEY=your-zhipu-api-key
|
|
||||||
ZHIPU_MODEL_NAME=your-zhipu-model-name
|
|
||||||
|
|
||||||
// Auth
|
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||||
BETTER_AUTH_SECRET=your-better-auth-secret
|
|
||||||
BETTER_AUTH_URL=http://localhost:3000
|
|
||||||
GITHUB_CLIENT_ID=your-github-client-id
|
|
||||||
GITHUB_CLIENT_SECRET=your-github-client-secret
|
|
||||||
|
|
||||||
// Database
|
## Learn More
|
||||||
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
|
|
||||||
```
|
|
||||||
|
|
||||||
注意:所有带 `your-` 前缀的值需要替换为你的实际配置。
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|
||||||
4. 初始化数据库
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||||
```bash
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
pnpm prisma generate
|
|
||||||
pnpm prisma db push
|
|
||||||
```
|
|
||||||
|
|
||||||
5. 启动开发服务器
|
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||||
```bash
|
|
||||||
pnpm run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
访问 [http://localhost:3000](http://localhost:3000) 查看应用。
|
## Deploy on Vercel
|
||||||
|
|
||||||
## 📚 API 文档
|
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||||
|
|
||||||
### 认证系统
|
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||||
|
|
||||||
应用使用 better-auth 提供安全的用户认证系统,支持邮箱/密码登录和第三方登录。
|
|
||||||
|
|
||||||
### 数据模型
|
|
||||||
|
|
||||||
核心数据模型包括:
|
|
||||||
- **User** - 用户信息
|
|
||||||
- **Folder** - 学习资料文件夹
|
|
||||||
- **Pair** - 语言对(翻译对、词汇对等)
|
|
||||||
|
|
||||||
详细模型定义请参考 [prisma/schema.prisma](./prisma/schema.prisma)
|
|
||||||
|
|
||||||
## 🌍 国际化
|
|
||||||
|
|
||||||
应用支持多语言,当前语言文件位于 `messages/` 目录。添加新语言:
|
|
||||||
|
|
||||||
1. 在 `messages/` 目录创建对应语言的 JSON 文件
|
|
||||||
2. 在 `src/i18n/config.ts` 中添加语言配置
|
|
||||||
|
|
||||||
## 🤝 贡献指南
|
|
||||||
|
|
||||||
我们欢迎各种形式的贡献!请遵循以下步骤:
|
|
||||||
|
|
||||||
1. Fork 项目
|
|
||||||
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
||||||
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
||||||
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
||||||
5. 打开 Pull Request
|
|
||||||
|
|
||||||
## 📄 许可证
|
|
||||||
|
|
||||||
本项目采用 AGPL-3.0 许可证 - 查看 [LICENSE](./LICENSE) 文件了解详情。
|
|
||||||
|
|
||||||
## 📞 支持
|
|
||||||
|
|
||||||
如果您遇到问题或有建议,请通过以下方式联系:
|
|
||||||
|
|
||||||
- 提交 [Issue](../../issues)
|
|
||||||
- 发送邮件至 [goddonebianu@outlook.com]
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Happy Learning!** 🌟
|
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
import { dirname } from "path";
|
||||||
import nextVitals from 'eslint-config-next/core-web-vitals'
|
import { fileURLToPath } from "url";
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc";
|
||||||
const eslintConfig = defineConfig([
|
|
||||||
...nextVitals,
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
// Override default ignores of eslint-config-next.
|
const __dirname = dirname(__filename);
|
||||||
globalIgnores([
|
|
||||||
// Default ignores of eslint-config-next:
|
const compat = new FlatCompat({
|
||||||
'.next/**',
|
baseDirectory: __dirname,
|
||||||
'out/**',
|
});
|
||||||
'build/**',
|
|
||||||
'next-env.d.ts',
|
const eslintConfig = [
|
||||||
]),
|
...compat.extends("next/core-web-vitals", "next/typescript"),
|
||||||
])
|
{
|
||||||
|
ignores: [
|
||||||
export default eslintConfig
|
"node_modules/**",
|
||||||
|
".next/**",
|
||||||
|
"out/**",
|
||||||
|
"build/**",
|
||||||
|
"next-env.d.ts",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default eslintConfig;
|
||||||
|
|||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "Bitte wählen Sie die Zeichen aus, die Sie lernen möchten",
|
|
||||||
"japanese": "Japanische Kana",
|
|
||||||
"english": "Englisches Alphabet",
|
|
||||||
"uyghur": "Uigurisches Alphabet",
|
|
||||||
"esperanto": "Esperanto-Alphabet",
|
|
||||||
"loading": "Laden...",
|
|
||||||
"loadFailed": "Laden fehlgeschlagen, bitte versuchen Sie es erneut",
|
|
||||||
"hideLetter": "Zeichen ausblenden",
|
|
||||||
"showLetter": "Zeichen anzeigen",
|
|
||||||
"hideIPA": "IPA ausblenden",
|
|
||||||
"showIPA": "IPA anzeigen",
|
|
||||||
"roman": "Romanisierung",
|
|
||||||
"letter": "Zeichen",
|
|
||||||
"random": "Zufälliger Modus",
|
|
||||||
"randomNext": "Zufällig weiter"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "Ordner",
|
|
||||||
"subtitle": "Verwalten Sie Ihre Sammlungen",
|
|
||||||
"newFolder": "Neuer Ordner",
|
|
||||||
"creating": "Erstellen...",
|
|
||||||
"noFoldersYet": "Noch keine Ordner",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs} Paare",
|
|
||||||
"enterFolderName": "Ordnernamen eingeben:",
|
|
||||||
"confirmDelete": "Geben Sie \"{name}\" ein, um zu löschen:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "Sie sind nicht der Eigentümer dieses Ordners",
|
|
||||||
"back": "Zurück",
|
|
||||||
"textPairs": "Textpaare",
|
|
||||||
"itemsCount": "{count} Elemente",
|
|
||||||
"memorize": "Einprägen",
|
|
||||||
"loadingTextPairs": "Textpaare werden geladen...",
|
|
||||||
"noTextPairs": "Keine Textpaare in diesem Ordner",
|
|
||||||
"addNewTextPair": "Neues Textpaar hinzufügen",
|
|
||||||
"add": "Hinzufügen",
|
|
||||||
"updateTextPair": "Textpaar aktualisieren",
|
|
||||||
"update": "Aktualisieren",
|
|
||||||
"text1": "Text 1",
|
|
||||||
"text2": "Text 2",
|
|
||||||
"language1": "Sprache 1",
|
|
||||||
"language2": "Sprache 2",
|
|
||||||
"enterLanguageName": "Bitte geben Sie den Sprachennamen ein",
|
|
||||||
"edit": "Bearbeiten",
|
|
||||||
"delete": "Löschen"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "Sprachen lernen",
|
|
||||||
"description": "Hier ist eine sehr nützliche Website, die Ihnen hilft, fast jede Sprache der Welt zu lernen, einschließlich konstruierter Sprachen.",
|
|
||||||
"explore": "Erkunden",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Bleib hungrig, bleiv dumm.",
|
|
||||||
"author": "— Steve Jobs"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "Übersetzer",
|
|
||||||
"description": "In jede Sprache übersetzen und mit Internationalem Phonetischem Alphabet (IPA) annotieren"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "Text-Sprecher",
|
|
||||||
"description": "Text erkennen und vorlesen, unterstützt Schleifenwiedergabe und Geschwindigkeitsanpassung"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "SRT-Videoplayer",
|
|
||||||
"description": "Videos basierend auf SRT-Untertiteldateien satzweise abspielen, um die Aussprache von Muttersprachlern zu imitieren"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "Alphabet",
|
|
||||||
"description": "Beginnen Sie mit dem Erlernen einer neuen Sprache mit dem Alphabet"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "Einprägen",
|
|
||||||
"description": "Sprache A zu Sprache B, Sprache B zu Sprache A, unterstützt Diktat"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "Wörterbuch",
|
|
||||||
"description": "Wörter und Redewendungen nachschlagen mit detaillierten Definitionen und Beispielen"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "Weitere Funktionen",
|
|
||||||
"description": "In Entwicklung, bleiben Sie dran"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "Authentifizierung",
|
|
||||||
"signIn": "Anmelden",
|
|
||||||
"signUp": "Registrieren",
|
|
||||||
"email": "E-Mail",
|
|
||||||
"password": "Passwort",
|
|
||||||
"confirmPassword": "Passwort bestätigen",
|
|
||||||
"name": "Name",
|
|
||||||
"signInButton": "Anmelden",
|
|
||||||
"signUpButton": "Registrieren",
|
|
||||||
"noAccount": "Haben Sie kein Konto?",
|
|
||||||
"hasAccount": "Haben Sie bereits ein Konto?",
|
|
||||||
"signInWithGitHub": "Mit GitHub anmelden",
|
|
||||||
"signUpWithGitHub": "Mit GitHub registrieren",
|
|
||||||
"invalidEmail": "Bitte geben Sie eine gültige E-Mail-Adresse ein",
|
|
||||||
"passwordTooShort": "Das Passwort muss mindestens 8 Zeichen lang sein",
|
|
||||||
"passwordsNotMatch": "Passwörter stimmen nicht überein",
|
|
||||||
"nameRequired": "Bitte geben Sie Ihren Namen ein",
|
|
||||||
"emailRequired": "Bitte geben Sie Ihre E-Mail ein",
|
|
||||||
"passwordRequired": "Bitte geben Sie Ihr Passwort ein",
|
|
||||||
"confirmPasswordRequired": "Bitte bestätigen Sie Ihr Passwort",
|
|
||||||
"loading": "Laden..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "Wählen Sie einen Ordner aus",
|
|
||||||
"noFolders": "Keine Ordner gefunden",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "Antwort",
|
|
||||||
"next": "Weiter",
|
|
||||||
"reverse": "Umkehren",
|
|
||||||
"dictation": "Diktat",
|
|
||||||
"noTextPairs": "Keine Textpaare verfügbar",
|
|
||||||
"disorder": "Mischen",
|
|
||||||
"previous": "Zurück"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "Sie sind nicht berechtigt, auf diesen Ordner zuzugreifen"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "Anmelden",
|
|
||||||
"profile": "Profil",
|
|
||||||
"folders": "Ordner"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "Mein Profil",
|
|
||||||
"email": "E-Mail: {email}",
|
|
||||||
"logout": "Abmelden"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "Video hochladen",
|
|
||||||
"uploadSubtitle": "Untertitel hochladen",
|
|
||||||
"pause": "Pause",
|
|
||||||
"play": "Abspielen",
|
|
||||||
"previous": "Zurück",
|
|
||||||
"next": "Weiter",
|
|
||||||
"restart": "Neustart",
|
|
||||||
"autoPause": "Auto-Pause ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "Bitte laden Sie Video- und Untertiteldateien hoch",
|
|
||||||
"uploadVideoFile": "Bitte laden Sie eine Videodatei hoch",
|
|
||||||
"uploadSubtitleFile": "Bitte laden Sie eine Untertiteldatei hoch",
|
|
||||||
"processingSubtitle": "Untertiteldatei wird verarbeitet...",
|
|
||||||
"needBothFiles": "Sowohl Video- als auch Untertiteldateien sind erforderlich, um mit dem Lernen zu beginnen",
|
|
||||||
"videoFile": "Videodatei",
|
|
||||||
"subtitleFile": "Untertiteldatei",
|
|
||||||
"uploaded": "Hochgeladen",
|
|
||||||
"notUploaded": "Nicht hochgeladen",
|
|
||||||
"upload": "Hochladen",
|
|
||||||
"autoPauseStatus": "Auto-Pause: {enabled}",
|
|
||||||
"on": "Ein",
|
|
||||||
"off": "Aus",
|
|
||||||
"videoUploadFailed": "Video-Upload fehlgeschlagen",
|
|
||||||
"subtitleUploadFailed": "Untertitel-Upload fehlgeschlagen"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "IPA generieren",
|
|
||||||
"viewSavedItems": "Gespeicherte Elemente anzeigen",
|
|
||||||
"confirmDeleteAll": "Sind Sie sicher, dass Sie alles löschen möchten? (J/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "Sprache erkennen",
|
|
||||||
"generateIPA": "IPA generieren",
|
|
||||||
"translateInto": "Übersetzen in",
|
|
||||||
"chinese": "Chinesisch",
|
|
||||||
"english": "Englisch",
|
|
||||||
"italian": "Italienisch",
|
|
||||||
"other": "Andere",
|
|
||||||
"translating": "Übersetzung läuft...",
|
|
||||||
"translate": "Übersetzen",
|
|
||||||
"inputLanguage": "Geben Sie eine Sprache ein.",
|
|
||||||
"history": "Verlauf",
|
|
||||||
"enterLanguage": "Sprache eingeben",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "Sie sind nicht authentifiziert",
|
|
||||||
"chooseFolder": "Wählen Sie einen Ordner zum Hinzufügen aus",
|
|
||||||
"noFolders": "Keine Ordner gefunden",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "Schließen",
|
|
||||||
"success": "Textpaar zum Ordner hinzugefügt",
|
|
||||||
"error": "Textpaar konnte nicht zum Ordner hinzugefügt werden"
|
|
||||||
},
|
|
||||||
"autoSave": "Automatisch speichern"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "Wörterbuch",
|
|
||||||
"description": "Wörter und Ausdrücke mit detaillierten Definitionen und Beispielen nachschlagen",
|
|
||||||
"searchPlaceholder": "Wort oder Ausdruck zum Nachschlagen eingeben...",
|
|
||||||
"searching": "Suche...",
|
|
||||||
"search": "Suchen",
|
|
||||||
"languageSettings": "Spracheinstellungen",
|
|
||||||
"queryLanguage": "Abfragesprache",
|
|
||||||
"queryLanguageHint": "Welche Sprache hat das Wort/die Phrase, die Sie nachschlagen möchten",
|
|
||||||
"definitionLanguage": "Definitionssprache",
|
|
||||||
"definitionLanguageHint": "In welcher Sprache möchten Sie die Definitionen sehen",
|
|
||||||
"otherLanguagePlaceholder": "Oder eine andere Sprache eingeben...",
|
|
||||||
"currentSettings": "Aktuelle Einstellungen: Abfrage {queryLang}, Definition {definitionLang}",
|
|
||||||
"relookup": "Neu suchen",
|
|
||||||
"saveToFolder": "In Ordner speichern",
|
|
||||||
"loading": "Laden...",
|
|
||||||
"noResults": "Keine Ergebnisse gefunden",
|
|
||||||
"tryOtherWords": "Versuchen Sie andere Wörter oder Ausdrücke",
|
|
||||||
"welcomeTitle": "Willkommen beim Wörterbuch",
|
|
||||||
"welcomeHint": "Geben Sie oben im Suchfeld ein Wort oder einen Ausdruck ein, um zu suchen",
|
|
||||||
"lookupFailed": "Suche fehlgeschlagen, bitte später erneut versuchen",
|
|
||||||
"relookupSuccess": "Erfolgreich neu gesucht",
|
|
||||||
"relookupFailed": "Wörterbuch Neu-Suche fehlgeschlagen",
|
|
||||||
"pleaseLogin": "Bitte melden Sie sich zuerst an",
|
|
||||||
"pleaseCreateFolder": "Bitte erstellen Sie zuerst einen Ordner",
|
|
||||||
"savedToFolder": "Im Ordner gespeichert: {folderName}",
|
|
||||||
"saveFailed": "Speichern fehlgeschlagen, bitte später erneut versuchen"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "Please select the characters you want to learn",
|
|
||||||
"japanese": "Japanese Kana",
|
|
||||||
"english": "English Alphabet",
|
|
||||||
"uyghur": "Uyghur Alphabet",
|
|
||||||
"esperanto": "Esperanto Alphabet",
|
|
||||||
"loading": "Loading...",
|
|
||||||
"loadFailed": "Loading failed, please try again",
|
|
||||||
"hideLetter": "Hide Letter",
|
|
||||||
"showLetter": "Show Letter",
|
|
||||||
"hideIPA": "Hide IPA",
|
|
||||||
"showIPA": "Show IPA",
|
|
||||||
"roman": "Romanization",
|
|
||||||
"letter": "Letter",
|
|
||||||
"random": "Random Mode",
|
|
||||||
"randomNext": "Random Next"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "Folders",
|
|
||||||
"subtitle": "Manage your collections",
|
|
||||||
"newFolder": "New Folder",
|
|
||||||
"creating": "Creating...",
|
|
||||||
"noFoldersYet": "No folders yet",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs} pairs",
|
|
||||||
"enterFolderName": "Enter folder name:",
|
|
||||||
"confirmDelete": "Type \"{name}\" to delete:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "You are not the owner of this folder",
|
|
||||||
"back": "Back",
|
|
||||||
"textPairs": "Text Pairs",
|
|
||||||
"itemsCount": "{count} items",
|
|
||||||
"memorize": "Memorize",
|
|
||||||
"loadingTextPairs": "Loading text pairs...",
|
|
||||||
"noTextPairs": "No text pairs in this folder",
|
|
||||||
"addNewTextPair": "Add New Text Pair",
|
|
||||||
"add": "Add",
|
|
||||||
"updateTextPair": "Update Text Pair",
|
|
||||||
"update": "Update",
|
|
||||||
"text1": "Text 1",
|
|
||||||
"text2": "Text 2",
|
|
||||||
"language1": "Locale 1",
|
|
||||||
"language2": "Locale 2",
|
|
||||||
"enterLanguageName": "Please enter language name",
|
|
||||||
"edit": "Edit",
|
|
||||||
"delete": "Delete"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "Learn Languages",
|
|
||||||
"description": "Here is a very useful website to help you learn almost every language in the world, including constructed ones.",
|
|
||||||
"explore": "Explore",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— Steve Jobs"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "Translator",
|
|
||||||
"description": "Translate to any language and annotate with International Phonetic Alphabet (IPA)"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "Text Speaker",
|
|
||||||
"description": "Recognize and read text aloud, supports loop playback and speed adjustment"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "SRT Video Player",
|
|
||||||
"description": "Play videos sentence by sentence based on SRT subtitle files to mimic native speaker pronunciation"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "Alphabet",
|
|
||||||
"description": "Start learning a new language from the alphabet"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "Memorize",
|
|
||||||
"description": "Language A to Language B, Language B to Language A, supports dictation"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "Dictionary",
|
|
||||||
"description": "Look up words and phrases with detailed definitions and examples"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "More Features",
|
|
||||||
"description": "Under development, stay tuned"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "Authentication",
|
|
||||||
"signIn": "Sign In",
|
|
||||||
"signUp": "Sign Up",
|
|
||||||
"email": "Email",
|
|
||||||
"password": "Password",
|
|
||||||
"confirmPassword": "Confirm Password",
|
|
||||||
"name": "Name",
|
|
||||||
"signInButton": "Sign In",
|
|
||||||
"signUpButton": "Sign Up",
|
|
||||||
"noAccount": "Don't have an account?",
|
|
||||||
"hasAccount": "Already have an account?",
|
|
||||||
"signInWithGitHub": "Sign In with GitHub",
|
|
||||||
"signUpWithGitHub": "Sign Up with GitHub",
|
|
||||||
"invalidEmail": "Please enter a valid email address",
|
|
||||||
"passwordTooShort": "Password must be at least 8 characters",
|
|
||||||
"passwordsNotMatch": "Passwords do not match",
|
|
||||||
"nameRequired": "Please enter your name",
|
|
||||||
"emailRequired": "Please enter your email",
|
|
||||||
"passwordRequired": "Please enter your password",
|
|
||||||
"confirmPasswordRequired": "Please confirm your password",
|
|
||||||
"loading": "Loading..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "Select a folder",
|
|
||||||
"noFolders": "No folders found",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "Answer",
|
|
||||||
"next": "Next",
|
|
||||||
"reverse": "Reverse",
|
|
||||||
"dictation": "Dictation",
|
|
||||||
"noTextPairs": "No text pairs available",
|
|
||||||
"disorder": "Disorder",
|
|
||||||
"previous": "Previous"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "You are not authorized to access this folder"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "Sign In",
|
|
||||||
"profile": "Profile",
|
|
||||||
"folders": "Folders"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "My Profile",
|
|
||||||
"email": "Email: {email}",
|
|
||||||
"logout": "Logout"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "Upload Video",
|
|
||||||
"uploadSubtitle": "Upload Subtitle",
|
|
||||||
"pause": "Pause",
|
|
||||||
"play": "Play",
|
|
||||||
"previous": "Previous",
|
|
||||||
"next": "Next",
|
|
||||||
"restart": "Restart",
|
|
||||||
"autoPause": "Auto Pause ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "Please upload video and subtitle files",
|
|
||||||
"uploadVideoFile": "Please upload video file",
|
|
||||||
"uploadSubtitleFile": "Please upload subtitle file",
|
|
||||||
"processingSubtitle": "Processing subtitle file...",
|
|
||||||
"needBothFiles": "Both video and subtitle files are required to start learning",
|
|
||||||
"videoFile": "Video File",
|
|
||||||
"subtitleFile": "Subtitle File",
|
|
||||||
"uploaded": "Uploaded",
|
|
||||||
"notUploaded": "Not Uploaded",
|
|
||||||
"upload": "Upload",
|
|
||||||
"autoPauseStatus": "Auto Pause: {enabled}",
|
|
||||||
"on": "On",
|
|
||||||
"off": "Off",
|
|
||||||
"videoUploadFailed": "Video upload failed",
|
|
||||||
"subtitleUploadFailed": "Subtitle upload failed"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "Generate IPA",
|
|
||||||
"viewSavedItems": "View Saved Items",
|
|
||||||
"confirmDeleteAll": "Are you sure you want to delete everything? (Y/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "detect language",
|
|
||||||
"generateIPA": "generate ipa",
|
|
||||||
"translateInto": "translate into",
|
|
||||||
"chinese": "Chinese",
|
|
||||||
"english": "English",
|
|
||||||
"italian": "Italian",
|
|
||||||
"other": "Other",
|
|
||||||
"translating": "translating...",
|
|
||||||
"translate": "translate",
|
|
||||||
"inputLanguage": "Input a language.",
|
|
||||||
"history": "History",
|
|
||||||
"enterLanguage": "Enter language",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "You are not authenticated",
|
|
||||||
"chooseFolder": "Choose a Folder to Add to",
|
|
||||||
"noFolders": "No folders found",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "Close",
|
|
||||||
"success": "Text pair added to folder",
|
|
||||||
"error": "Failed to add text pair to folder"
|
|
||||||
},
|
|
||||||
"autoSave": "Auto Save"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "Dictionary",
|
|
||||||
"description": "Look up words and phrases with detailed definitions and examples",
|
|
||||||
"searchPlaceholder": "Enter a word or phrase to look up...",
|
|
||||||
"searching": "Searching...",
|
|
||||||
"search": "Search",
|
|
||||||
"languageSettings": "Language Settings",
|
|
||||||
"queryLanguage": "Query Language",
|
|
||||||
"queryLanguageHint": "What language is the word/phrase you want to look up",
|
|
||||||
"definitionLanguage": "Definition Language",
|
|
||||||
"definitionLanguageHint": "What language do you want the definitions in",
|
|
||||||
"otherLanguagePlaceholder": "Or enter another language...",
|
|
||||||
"currentSettings": "Current settings: Query {queryLang}, Definition {definitionLang}",
|
|
||||||
"relookup": "Re-search",
|
|
||||||
"saveToFolder": "Save to folder",
|
|
||||||
"loading": "Loading...",
|
|
||||||
"noResults": "No results found",
|
|
||||||
"tryOtherWords": "Try other words or phrases",
|
|
||||||
"welcomeTitle": "Welcome to Dictionary",
|
|
||||||
"welcomeHint": "Enter a word or phrase in the search box above to start looking up",
|
|
||||||
"lookupFailed": "Search failed, please try again later",
|
|
||||||
"relookupSuccess": "Re-searched successfully",
|
|
||||||
"relookupFailed": "Dictionary re-search failed",
|
|
||||||
"pleaseLogin": "Please log in first",
|
|
||||||
"pleaseCreateFolder": "Please create a folder first",
|
|
||||||
"savedToFolder": "Saved to folder: {folderName}",
|
|
||||||
"saveFailed": "Save failed, please try again later"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "Veuillez sélectionner les caractères que vous souhaitez apprendre",
|
|
||||||
"japanese": "Kana japonais",
|
|
||||||
"english": "Alphabet anglais",
|
|
||||||
"uyghur": "Alphabet ouïghour",
|
|
||||||
"esperanto": "Alphabet espéranto",
|
|
||||||
"loading": "Chargement...",
|
|
||||||
"loadFailed": "Échec du chargement, veuillez réessayer",
|
|
||||||
"hideLetter": "Masquer la lettre",
|
|
||||||
"showLetter": "Afficher la lettre",
|
|
||||||
"hideIPA": "Masquer l'API",
|
|
||||||
"showIPA": "Afficher l'API",
|
|
||||||
"roman": "Romanisation",
|
|
||||||
"letter": "Lettre",
|
|
||||||
"random": "Mode aléatoire",
|
|
||||||
"randomNext": "Suivant aléatoire"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "Dossiers",
|
|
||||||
"subtitle": "Gérez vos collections",
|
|
||||||
"newFolder": "Nouveau dossier",
|
|
||||||
"creating": "Création...",
|
|
||||||
"noFoldersYet": "Aucun dossier pour le moment",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs} paires",
|
|
||||||
"enterFolderName": "Entrez le nom du dossier:",
|
|
||||||
"confirmDelete": "Tapez \"{name}\" pour supprimer:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "Vous n'êtes pas le propriétaire de ce dossier",
|
|
||||||
"back": "Retour",
|
|
||||||
"textPairs": "Paires de textes",
|
|
||||||
"itemsCount": "{count} éléments",
|
|
||||||
"memorize": "Mémoriser",
|
|
||||||
"loadingTextPairs": "Chargement des paires de textes...",
|
|
||||||
"noTextPairs": "Aucune paire de textes dans ce dossier",
|
|
||||||
"addNewTextPair": "Ajouter une nouvelle paire de textes",
|
|
||||||
"add": "Ajouter",
|
|
||||||
"updateTextPair": "Mettre à jour la paire de textes",
|
|
||||||
"update": "Mettre à jour",
|
|
||||||
"text1": "Texte 1",
|
|
||||||
"text2": "Texte 2",
|
|
||||||
"language1": "Langue 1",
|
|
||||||
"language2": "Langue 2",
|
|
||||||
"enterLanguageName": "Veuillez entrer le nom de la langue",
|
|
||||||
"edit": "Modifier",
|
|
||||||
"delete": "Supprimer"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "Apprendre les langues",
|
|
||||||
"description": "Voici un site web très utile pour vous aider à apprendre presque toutes les langues du monde, y compris les langues construites.",
|
|
||||||
"explore": "Explorer",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— Steve Jobs"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "Traducteur",
|
|
||||||
"description": "Traduire dans n'importe quelle langue et annoter avec l'alphabet phonétique international (API)"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "Lecteur de texte",
|
|
||||||
"description": "Reconnaître et lire le texte à haute voix, prend en charge la lecture en boucle et le réglage de la vitesse"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "Lecteur vidéo SRT",
|
|
||||||
"description": "Lire des vidéos phrase par phrase basées sur des fichiers de sous-titres SRT pour imiter la prononciation des locuteurs natifs"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "Alphabet",
|
|
||||||
"description": "Commencer à apprendre une nouvelle langue par l'alphabet"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "Mémoriser",
|
|
||||||
"description": "Langue A vers langue B, langue B vers langue A, prend en charge la dictée"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "Dictionnaire",
|
|
||||||
"description": "Rechercher des mots et des phrases avec des définitions détaillées et des exemples"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "Plus de fonctionnalités",
|
|
||||||
"description": "En développement, restez à l'écoute"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "Authentification",
|
|
||||||
"signIn": "Se connecter",
|
|
||||||
"signUp": "S'inscrire",
|
|
||||||
"email": "E-mail",
|
|
||||||
"password": "Mot de passe",
|
|
||||||
"confirmPassword": "Confirmer le mot de passe",
|
|
||||||
"name": "Nom",
|
|
||||||
"signInButton": "Se connecter",
|
|
||||||
"signUpButton": "S'inscrire",
|
|
||||||
"noAccount": "Vous n'avez pas de compte?",
|
|
||||||
"hasAccount": "Vous avez déjà un compte?",
|
|
||||||
"signInWithGitHub": "Se connecter avec GitHub",
|
|
||||||
"signUpWithGitHub": "S'inscrire avec GitHub",
|
|
||||||
"invalidEmail": "Veuillez entrer une adresse e-mail valide",
|
|
||||||
"passwordTooShort": "Le mot de passe doit contenir au moins 8 caractères",
|
|
||||||
"passwordsNotMatch": "Les mots de passe ne correspondent pas",
|
|
||||||
"nameRequired": "Veuillez entrer votre nom",
|
|
||||||
"emailRequired": "Veuillez entrer votre e-mail",
|
|
||||||
"passwordRequired": "Veuillez entrer votre mot de passe",
|
|
||||||
"confirmPasswordRequired": "Veuillez confirmer votre mot de passe",
|
|
||||||
"loading": "Chargement..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "Sélectionner un dossier",
|
|
||||||
"noFolders": "Aucun dossier trouvé",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "Réponse",
|
|
||||||
"next": "Suivant",
|
|
||||||
"reverse": "Inverser",
|
|
||||||
"dictation": "Dictée",
|
|
||||||
"noTextPairs": "Aucune paire de textes disponible",
|
|
||||||
"disorder": "Désordre",
|
|
||||||
"previous": "Précédent"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "Vous n'êtes pas autorisé à accéder à ce dossier"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "Se connecter",
|
|
||||||
"profile": "Profil",
|
|
||||||
"folders": "Dossiers"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "Mon profil",
|
|
||||||
"email": "E-mail: {email}",
|
|
||||||
"logout": "Se déconnecter"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "Télécharger une vidéo",
|
|
||||||
"uploadSubtitle": "Télécharger des sous-titres",
|
|
||||||
"pause": "Pause",
|
|
||||||
"play": "Lire",
|
|
||||||
"previous": "Précédent",
|
|
||||||
"next": "Suivant",
|
|
||||||
"restart": "Redémarrer",
|
|
||||||
"autoPause": "Pause automatique ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "Veuillez télécharger des fichiers vidéo et de sous-titres",
|
|
||||||
"uploadVideoFile": "Veuillez télécharger un fichier vidéo",
|
|
||||||
"uploadSubtitleFile": "Veuillez télécharger un fichier de sous-titres",
|
|
||||||
"processingSubtitle": "Traitement du fichier de sous-titres...",
|
|
||||||
"needBothFiles": "Les fichiers vidéo et de sous-titres sont requis pour commencer l'apprentissage",
|
|
||||||
"videoFile": "Fichier vidéo",
|
|
||||||
"subtitleFile": "Fichier de sous-titres",
|
|
||||||
"uploaded": "Téléchargé",
|
|
||||||
"notUploaded": "Non téléchargé",
|
|
||||||
"upload": "Télécharger",
|
|
||||||
"autoPauseStatus": "Pause automatique: {enabled}",
|
|
||||||
"on": "Activé",
|
|
||||||
"off": "Désactivé",
|
|
||||||
"videoUploadFailed": "Échec du téléchargement de la vidéo",
|
|
||||||
"subtitleUploadFailed": "Échec du téléchargement des sous-titres"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "Générer l'API",
|
|
||||||
"viewSavedItems": "Voir les éléments enregistrés",
|
|
||||||
"confirmDeleteAll": "Êtes-vous sûr de vouloir tout supprimer? (O/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "détecter la langue",
|
|
||||||
"generateIPA": "générer l'api",
|
|
||||||
"translateInto": "traduire en",
|
|
||||||
"chinese": "Chinois",
|
|
||||||
"english": "Anglais",
|
|
||||||
"italian": "Italien",
|
|
||||||
"other": "Autre",
|
|
||||||
"translating": "traduction...",
|
|
||||||
"translate": "traduire",
|
|
||||||
"inputLanguage": "Entrez une langue.",
|
|
||||||
"history": "Historique",
|
|
||||||
"enterLanguage": "Entrer la langue",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "Vous n'êtes pas authentifié",
|
|
||||||
"chooseFolder": "Choisir un dossier à ajouter",
|
|
||||||
"noFolders": "Aucun dossier trouvé",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "Fermer",
|
|
||||||
"success": "Paire de textes ajoutée au dossier",
|
|
||||||
"error": "Échec de l'ajout de la paire de textes au dossier"
|
|
||||||
},
|
|
||||||
"autoSave": "Sauvegarde automatique"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "Dictionnaire",
|
|
||||||
"description": "Rechercher des mots et des phrases avec des définitions détaillées et des exemples",
|
|
||||||
"searchPlaceholder": "Entrez un mot ou une phrase à rechercher...",
|
|
||||||
"searching": "Recherche...",
|
|
||||||
"search": "Rechercher",
|
|
||||||
"languageSettings": "Paramètres linguistiques",
|
|
||||||
"queryLanguage": "Langue de requête",
|
|
||||||
"queryLanguageHint": "Quelle est la langue du mot/phrase que vous souhaitez rechercher",
|
|
||||||
"definitionLanguage": "Langue de définition",
|
|
||||||
"definitionLanguageHint": "Dans quelle langue souhaitez-vous voir les définitions",
|
|
||||||
"otherLanguagePlaceholder": "Ou entrez une autre langue...",
|
|
||||||
"currentSettings": "Paramètres actuels : Requête {queryLang}, Définition {definitionLang}",
|
|
||||||
"relookup": "Rechercher à nouveau",
|
|
||||||
"saveToFolder": "Enregistrer dans le dossier",
|
|
||||||
"loading": "Chargement...",
|
|
||||||
"noResults": "Aucun résultat trouvé",
|
|
||||||
"tryOtherWords": "Essayez d'autres mots ou phrases",
|
|
||||||
"welcomeTitle": "Bienvenue dans le dictionnaire",
|
|
||||||
"welcomeHint": "Entrez un mot ou une phrase dans la zone de recherche ci-dessus pour commencer",
|
|
||||||
"lookupFailed": "Recherche échouée, veuillez réessayer plus tard",
|
|
||||||
"relookupSuccess": "Recherche répétée avec succès",
|
|
||||||
"relookupFailed": "Nouvelle recherche de dictionnaire échouée",
|
|
||||||
"pleaseLogin": "Veuillez d'abord vous connecter",
|
|
||||||
"pleaseCreateFolder": "Veuillez d'abord créer un dossier",
|
|
||||||
"savedToFolder": "Enregistré dans le dossier : {folderName}",
|
|
||||||
"saveFailed": "Échec de l'enregistrement, veuillez réessayer plus tard"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "Seleziona i caratteri che desideri imparare",
|
|
||||||
"japanese": "Kana giapponese",
|
|
||||||
"english": "Alfabeto inglese",
|
|
||||||
"uyghur": "Alfabeto uiguro",
|
|
||||||
"esperanto": "Alfabeto esperanto",
|
|
||||||
"loading": "Caricamento...",
|
|
||||||
"loadFailed": "Caricamento fallito, riprova",
|
|
||||||
"hideLetter": "Nascondi lettera",
|
|
||||||
"showLetter": "Mostra lettera",
|
|
||||||
"hideIPA": "Nascondi IPA",
|
|
||||||
"showIPA": "Mostra IPA",
|
|
||||||
"roman": "Romanizzazione",
|
|
||||||
"letter": "Lettera",
|
|
||||||
"random": "Modalità casuale",
|
|
||||||
"randomNext": "Successivo casuale"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "Cartelle",
|
|
||||||
"subtitle": "Gestisci le tue collezioni",
|
|
||||||
"newFolder": "Nuova cartella",
|
|
||||||
"creating": "Creazione...",
|
|
||||||
"noFoldersYet": "Nessuna cartella ancora",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs} coppie",
|
|
||||||
"enterFolderName": "Inserisci nome cartella:",
|
|
||||||
"confirmDelete": "Digita \"{name}\" per eliminare:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "Non sei il proprietario di questa cartella",
|
|
||||||
"back": "Indietro",
|
|
||||||
"textPairs": "Coppie di testi",
|
|
||||||
"itemsCount": "{count} elementi",
|
|
||||||
"memorize": "Memorizza",
|
|
||||||
"loadingTextPairs": "Caricamento coppie di testi...",
|
|
||||||
"noTextPairs": "Nessuna coppia di testi in questa cartella",
|
|
||||||
"addNewTextPair": "Aggiungi nuova coppia di testi",
|
|
||||||
"add": "Aggiungi",
|
|
||||||
"updateTextPair": "Aggiorna coppia di testi",
|
|
||||||
"update": "Aggiorna",
|
|
||||||
"text1": "Testo 1",
|
|
||||||
"text2": "Testo 2",
|
|
||||||
"language1": "Lingua 1",
|
|
||||||
"language2": "Lingua 2",
|
|
||||||
"enterLanguageName": "Inserisci il nome della lingua",
|
|
||||||
"edit": "Modifica",
|
|
||||||
"delete": "Elimina"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "Impara le lingue",
|
|
||||||
"description": "Questo è un sito web molto utile che ti aiuta a imparare quasi tutte le lingue del mondo, incluse quelle costruite.",
|
|
||||||
"explore": "Esplora",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— Steve Jobs"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "Traduttore",
|
|
||||||
"description": "Traduci in qualsiasi lingua e annota con l'alfabeto fonetico internazionale (IPA)"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "Lettore di testo",
|
|
||||||
"description": "Riconosce e legge il testo ad alta voce, supporta la riproduzione in loop e la regolazione della velocità"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "Lettore video SRT",
|
|
||||||
"description": "Riproduci video frase per frase basandoti su file di sottotitoli SRT per imitare la pronuncia dei madrelingua"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "Alfabeto",
|
|
||||||
"description": "Inizia a imparare una nuova lingua dall'alfabeto"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "Memorizza",
|
|
||||||
"description": "Lingua A verso lingua B, lingua B verso lingua A, supporta dettatura"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "Dizionario",
|
|
||||||
"description": "Cerca parole e frasi con definizioni dettagliate ed esempi"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "Altre funzionalità",
|
|
||||||
"description": "In sviluppo, rimani sintonizzato"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "Autenticazione",
|
|
||||||
"signIn": "Accedi",
|
|
||||||
"signUp": "Registrati",
|
|
||||||
"email": "Email",
|
|
||||||
"password": "Password",
|
|
||||||
"confirmPassword": "Conferma password",
|
|
||||||
"name": "Nome",
|
|
||||||
"signInButton": "Accedi",
|
|
||||||
"signUpButton": "Registrati",
|
|
||||||
"noAccount": "Non hai un account?",
|
|
||||||
"hasAccount": "Hai già un account?",
|
|
||||||
"signInWithGitHub": "Accedi con GitHub",
|
|
||||||
"signUpWithGitHub": "Registrati con GitHub",
|
|
||||||
"invalidEmail": "Inserisci un indirizzo email valido",
|
|
||||||
"passwordTooShort": "La password deve essere di almeno 8 caratteri",
|
|
||||||
"passwordsNotMatch": "Le password non corrispondono",
|
|
||||||
"nameRequired": "Inserisci il tuo nome",
|
|
||||||
"emailRequired": "Inserisci la tua email",
|
|
||||||
"passwordRequired": "Inserisci la tua password",
|
|
||||||
"confirmPasswordRequired": "Conferma la tua password",
|
|
||||||
"loading": "Caricamento..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "Seleziona una cartella",
|
|
||||||
"noFolders": "Nessuna cartella trovata",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "Risposta",
|
|
||||||
"next": "Successivo",
|
|
||||||
"reverse": "Inverti",
|
|
||||||
"dictation": "Dettatura",
|
|
||||||
"noTextPairs": "Nessuna coppia di testi disponibile",
|
|
||||||
"disorder": "Disordine",
|
|
||||||
"previous": "Precedente"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "Non sei autorizzato ad accedere a questa cartella"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "Accedi",
|
|
||||||
"profile": "Profilo",
|
|
||||||
"folders": "Cartelle"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "Il mio profilo",
|
|
||||||
"email": "Email: {email}",
|
|
||||||
"logout": "Esci"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "Carica video",
|
|
||||||
"uploadSubtitle": "Carica sottotitoli",
|
|
||||||
"pause": "Pausa",
|
|
||||||
"play": "Riproduci",
|
|
||||||
"previous": "Precedente",
|
|
||||||
"next": "Successivo",
|
|
||||||
"restart": "Riavvia",
|
|
||||||
"autoPause": "Pausa automatica ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "Carica i file video e sottotitoli",
|
|
||||||
"uploadVideoFile": "Carica un file video",
|
|
||||||
"uploadSubtitleFile": "Carica un file di sottotitoli",
|
|
||||||
"processingSubtitle": "Elaborazione file sottotitoli...",
|
|
||||||
"needBothFiles": "Sono richiesti sia i file video che i sottotitoli per iniziare l'apprendimento",
|
|
||||||
"videoFile": "File video",
|
|
||||||
"subtitleFile": "File sottotitoli",
|
|
||||||
"uploaded": "Caricato",
|
|
||||||
"notUploaded": "Non caricato",
|
|
||||||
"upload": "Carica",
|
|
||||||
"autoPauseStatus": "Pausa automatica: {enabled}",
|
|
||||||
"on": "Attivo",
|
|
||||||
"off": "Disattivo",
|
|
||||||
"videoUploadFailed": "Caricamento video fallito",
|
|
||||||
"subtitleUploadFailed": "Caricamento sottotitoli fallito"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "Genera IPA",
|
|
||||||
"viewSavedItems": "Visualizza elementi salvati",
|
|
||||||
"confirmDeleteAll": "Sei sicuro di voler eliminare tutto? (S/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "rileva lingua",
|
|
||||||
"generateIPA": "genera ipa",
|
|
||||||
"translateInto": "traduci in",
|
|
||||||
"chinese": "Cinese",
|
|
||||||
"english": "Inglese",
|
|
||||||
"italian": "Italiano",
|
|
||||||
"other": "Altro",
|
|
||||||
"translating": "traduzione...",
|
|
||||||
"translate": "traduci",
|
|
||||||
"inputLanguage": "Inserisci una lingua.",
|
|
||||||
"history": "Cronologia",
|
|
||||||
"enterLanguage": "Inserisci lingua",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "Non sei autenticato",
|
|
||||||
"chooseFolder": "Scegli una cartella a cui aggiungere",
|
|
||||||
"noFolders": "Nessuna cartella trovata",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "Chiudi",
|
|
||||||
"success": "Coppia di testi aggiunta alla cartella",
|
|
||||||
"error": "Impossibile aggiungere la coppia di testi alla cartella"
|
|
||||||
},
|
|
||||||
"autoSave": "Salvataggio automatico"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "Dizionario",
|
|
||||||
"description": "Cerca parole e frasi con definizioni dettagliate ed esempi",
|
|
||||||
"searchPlaceholder": "Inserisci una parola o frase da cercare...",
|
|
||||||
"searching": "Ricerca...",
|
|
||||||
"search": "Cerca",
|
|
||||||
"languageSettings": "Impostazioni lingua",
|
|
||||||
"queryLanguage": "Lingua di interrogazione",
|
|
||||||
"queryLanguageHint": "Quale è la lingua della parola/frase che vuoi cercare",
|
|
||||||
"definitionLanguage": "Lingua di definizione",
|
|
||||||
"definitionLanguageHint": "In quale lingua vuoi vedere le definizioni",
|
|
||||||
"otherLanguagePlaceholder": "Oppure inserisci un'altra lingua...",
|
|
||||||
"currentSettings": "Impostazioni attuali: Interrogazione {queryLang}, Definizione {definitionLang}",
|
|
||||||
"relookup": "Ricerca di nuovo",
|
|
||||||
"saveToFolder": "Salva nella cartella",
|
|
||||||
"loading": "Caricamento...",
|
|
||||||
"noResults": "Nessun risultato trovato",
|
|
||||||
"tryOtherWords": "Prova altre parole o frasi",
|
|
||||||
"welcomeTitle": "Benvenuto nel dizionario",
|
|
||||||
"welcomeHint": "Inserisci una parola o frase nella casella di ricerca sopra per iniziare",
|
|
||||||
"lookupFailed": "Ricerca fallita, riprova più tardi",
|
|
||||||
"relookupSuccess": "Ricerca ripetuta con successo",
|
|
||||||
"relookupFailed": "Nuova ricerca del dizionario fallita",
|
|
||||||
"pleaseLogin": "Accedi prima",
|
|
||||||
"pleaseCreateFolder": "Crea prima una cartella",
|
|
||||||
"savedToFolder": "Salvato nella cartella: {folderName}",
|
|
||||||
"saveFailed": "Salvataggio fallito, riprova più tardi"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "学習したい文字を選択してください",
|
|
||||||
"japanese": "日本語仮名",
|
|
||||||
"english": "英語アルファベット",
|
|
||||||
"uyghur": "ウイグル文字",
|
|
||||||
"esperanto": "エスペラント文字",
|
|
||||||
"loading": "読み込み中...",
|
|
||||||
"loadFailed": "読み込みに失敗しました。もう一度お試しください",
|
|
||||||
"hideLetter": "文字を非表示",
|
|
||||||
"showLetter": "文字を表示",
|
|
||||||
"hideIPA": "IPAを非表示",
|
|
||||||
"showIPA": "IPAを表示",
|
|
||||||
"roman": "ローマ字",
|
|
||||||
"letter": "文字",
|
|
||||||
"random": "ランダムモード",
|
|
||||||
"randomNext": "ランダムで次へ"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "フォルダー",
|
|
||||||
"subtitle": "コレクションを管理",
|
|
||||||
"newFolder": "新規フォルダー",
|
|
||||||
"creating": "作成中...",
|
|
||||||
"noFoldersYet": "フォルダーがありません",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs}組",
|
|
||||||
"enterFolderName": "フォルダー名を入力:",
|
|
||||||
"confirmDelete": "削除するには「{name}」と入力してください:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "あなたはこのフォルダーの所有者ではありません",
|
|
||||||
"back": "戻る",
|
|
||||||
"textPairs": "テキストペア",
|
|
||||||
"itemsCount": "{count}項目",
|
|
||||||
"memorize": "暗記",
|
|
||||||
"loadingTextPairs": "テキストペアを読み込み中...",
|
|
||||||
"noTextPairs": "このフォルダーにはテキストペアがありません",
|
|
||||||
"addNewTextPair": "新しいテキストペアを追加",
|
|
||||||
"add": "追加",
|
|
||||||
"updateTextPair": "テキストペアを更新",
|
|
||||||
"update": "更新",
|
|
||||||
"text1": "テキスト1",
|
|
||||||
"text2": "テキスト2",
|
|
||||||
"language1": "言語1",
|
|
||||||
"language2": "言語2",
|
|
||||||
"enterLanguageName": "言語名を入力してください",
|
|
||||||
"edit": "編集",
|
|
||||||
"delete": "削除"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "言語を学ぶ",
|
|
||||||
"description": "これは、人工言語を含む世界中のほぼすべての言語を学ぶのに役立つ非常に便利なウェブサイトです。",
|
|
||||||
"explore": "探索",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— スティーブ・ジョブズ"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "翻訳",
|
|
||||||
"description": "任意の言語に翻訳し、国際音声記号(IPA)で注釈を付けます"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "テキストスピーカー",
|
|
||||||
"description": "テキストを認識して音読します。ループ再生と速度調整をサポート"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "SRTビデオプレーヤー",
|
|
||||||
"description": "SRT字幕ファイルに基づいてビデオを文ごとに再生し、ネイティブスピーカーの発音を模倣します"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "アルファベット",
|
|
||||||
"description": "アルファベットから新しい言語の学習を始めましょう"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "暗記",
|
|
||||||
"description": "言語Aから言語B、言語Bから言語A、ディクテーションをサポート"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "辞書",
|
|
||||||
"description": "単語やフレーズを調べ、詳細な定義と例を表示"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "その他の機能",
|
|
||||||
"description": "開発中です。お楽しみに"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "認証",
|
|
||||||
"signIn": "ログイン",
|
|
||||||
"signUp": "新規登録",
|
|
||||||
"email": "メールアドレス",
|
|
||||||
"password": "パスワード",
|
|
||||||
"confirmPassword": "パスワード(確認)",
|
|
||||||
"name": "名前",
|
|
||||||
"signInButton": "ログイン",
|
|
||||||
"signUpButton": "新規登録",
|
|
||||||
"noAccount": "アカウントをお持ちでないですか?",
|
|
||||||
"hasAccount": "すでにアカウントをお持ちですか?",
|
|
||||||
"signInWithGitHub": "GitHubでログイン",
|
|
||||||
"signUpWithGitHub": "GitHubで新規登録",
|
|
||||||
"invalidEmail": "有効なメールアドレスを入力してください",
|
|
||||||
"passwordTooShort": "パスワードは8文字以上である必要があります",
|
|
||||||
"passwordsNotMatch": "パスワードが一致しません",
|
|
||||||
"nameRequired": "名前を入力してください",
|
|
||||||
"emailRequired": "メールアドレスを入力してください",
|
|
||||||
"passwordRequired": "パスワードを入力してください",
|
|
||||||
"confirmPasswordRequired": "パスワード(確認)を入力してください",
|
|
||||||
"loading": "読み込み中..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "フォルダーを選択",
|
|
||||||
"noFolders": "フォルダーが見つかりません",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "回答",
|
|
||||||
"next": "次へ",
|
|
||||||
"reverse": "逆順",
|
|
||||||
"dictation": "ディクテーション",
|
|
||||||
"noTextPairs": "利用可能なテキストペアがありません",
|
|
||||||
"disorder": "ランダム",
|
|
||||||
"previous": "前へ"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "このフォルダーにアクセスする権限がありません"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "ログイン",
|
|
||||||
"profile": "プロフィール",
|
|
||||||
"folders": "フォルダー"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "マイプロフィール",
|
|
||||||
"email": "メールアドレス: {email}",
|
|
||||||
"logout": "ログアウト"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "ビデオをアップロード",
|
|
||||||
"uploadSubtitle": "字幕をアップロード",
|
|
||||||
"pause": "一時停止",
|
|
||||||
"play": "再生",
|
|
||||||
"previous": "前へ",
|
|
||||||
"next": "次へ",
|
|
||||||
"restart": "最初から",
|
|
||||||
"autoPause": "自動一時停止 ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "ビデオと字幕ファイルをアップロードしてください",
|
|
||||||
"uploadVideoFile": "ビデオファイルをアップロードしてください",
|
|
||||||
"uploadSubtitleFile": "字幕ファイルをアップロードしてください",
|
|
||||||
"processingSubtitle": "字幕ファイルを処理中...",
|
|
||||||
"needBothFiles": "学習を開始するにはビデオと字幕ファイルの両方が必要です",
|
|
||||||
"videoFile": "ビデオファイル",
|
|
||||||
"subtitleFile": "字幕ファイル",
|
|
||||||
"uploaded": "アップロード済み",
|
|
||||||
"notUploaded": "未アップロード",
|
|
||||||
"upload": "アップロード",
|
|
||||||
"autoPauseStatus": "自動一時停止: {enabled}",
|
|
||||||
"on": "オン",
|
|
||||||
"off": "オフ",
|
|
||||||
"videoUploadFailed": "ビデオのアップロードに失敗しました",
|
|
||||||
"subtitleUploadFailed": "字幕のアップロードに失敗しました"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "IPAを生成",
|
|
||||||
"viewSavedItems": "保存済みアイテムを表示",
|
|
||||||
"confirmDeleteAll": "本当にすべて削除しますか? (Y/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "言語を検出",
|
|
||||||
"generateIPA": "IPAを生成",
|
|
||||||
"translateInto": "翻訳",
|
|
||||||
"chinese": "中国語",
|
|
||||||
"english": "英語",
|
|
||||||
"italian": "イタリア語",
|
|
||||||
"other": "その他",
|
|
||||||
"translating": "翻訳中...",
|
|
||||||
"translate": "翻訳",
|
|
||||||
"inputLanguage": "言語を入力してください。",
|
|
||||||
"history": "履歴",
|
|
||||||
"enterLanguage": "言語を入力",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "認証されていません",
|
|
||||||
"chooseFolder": "追加するフォルダーを選択",
|
|
||||||
"noFolders": "フォルダーが見つかりません",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "閉じる",
|
|
||||||
"success": "テキストペアをフォルダーに追加しました",
|
|
||||||
"error": "テキストペアの追加に失敗しました"
|
|
||||||
},
|
|
||||||
"autoSave": "自動保存"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "辞書",
|
|
||||||
"description": "詳細な定義と例で単語やフレーズを検索",
|
|
||||||
"searchPlaceholder": "検索する単語やフレーズを入力...",
|
|
||||||
"searching": "検索中...",
|
|
||||||
"search": "検索",
|
|
||||||
"languageSettings": "言語設定",
|
|
||||||
"queryLanguage": "クエリ言語",
|
|
||||||
"queryLanguageHint": "検索する単語/フレーズの言語",
|
|
||||||
"definitionLanguage": "定義言語",
|
|
||||||
"definitionLanguageHint": "定義を表示する言語",
|
|
||||||
"otherLanguagePlaceholder": "または他の言語を入力...",
|
|
||||||
"currentSettings": "現在の設定:クエリ {queryLang}、定義 {definitionLang}",
|
|
||||||
"relookup": "再検索",
|
|
||||||
"saveToFolder": "フォルダに保存",
|
|
||||||
"loading": "読み込み中...",
|
|
||||||
"noResults": "結果が見つかりません",
|
|
||||||
"tryOtherWords": "他の単語やフレーズを試してください",
|
|
||||||
"welcomeTitle": "辞書へようこそ",
|
|
||||||
"welcomeHint": "上の検索ボックスに単語やフレーズを入力して検索を開始",
|
|
||||||
"lookupFailed": "検索に失敗しました。後でもう一度お試しください",
|
|
||||||
"relookupSuccess": "再検索しました",
|
|
||||||
"relookupFailed": "辞書の再検索に失敗しました",
|
|
||||||
"pleaseLogin": "まずログインしてください",
|
|
||||||
"pleaseCreateFolder": "まずフォルダを作成してください",
|
|
||||||
"savedToFolder": "フォルダに保存しました:{folderName}",
|
|
||||||
"saveFailed": "保存に失敗しました。後でもう一度お試しください"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "학습할 문자를 선택하세요",
|
|
||||||
"japanese": "일본어 가나",
|
|
||||||
"english": "영문 알파벳",
|
|
||||||
"uyghur": "위구르 문자",
|
|
||||||
"esperanto": "에스페란토 문자",
|
|
||||||
"loading": "로딩 중...",
|
|
||||||
"loadFailed": "로딩 실패, 다시 시도해 주세요",
|
|
||||||
"hideLetter": "문자 숨기기",
|
|
||||||
"showLetter": "문자 표시",
|
|
||||||
"hideIPA": "IPA 숨기기",
|
|
||||||
"showIPA": "IPA 표시",
|
|
||||||
"roman": "로마자 표기",
|
|
||||||
"letter": "문자",
|
|
||||||
"random": "무작위 모드",
|
|
||||||
"randomNext": "무작위 다음"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "폴더",
|
|
||||||
"subtitle": "컬렉션 관리",
|
|
||||||
"newFolder": "새 폴더",
|
|
||||||
"creating": "생성 중...",
|
|
||||||
"noFoldersYet": "폴더가 없습니다",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs}쌍",
|
|
||||||
"enterFolderName": "폴더 이름 입력:",
|
|
||||||
"confirmDelete": "삭제하려면 \"{name}\"을(를) 입력하세요:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "이 폴더의 소유자가 아닙니다",
|
|
||||||
"back": "뒤로",
|
|
||||||
"textPairs": "텍스트 쌍",
|
|
||||||
"itemsCount": "{count}개 항목",
|
|
||||||
"memorize": "암기",
|
|
||||||
"loadingTextPairs": "텍스트 쌍 로딩 중...",
|
|
||||||
"noTextPairs": "이 폴더에 텍스트 쌍이 없습니다",
|
|
||||||
"addNewTextPair": "새 텍스트 쌍 추가",
|
|
||||||
"add": "추가",
|
|
||||||
"updateTextPair": "텍스트 쌍 업데이트",
|
|
||||||
"update": "업데이트",
|
|
||||||
"text1": "텍스트 1",
|
|
||||||
"text2": "텍스트 2",
|
|
||||||
"language1": "언어 1",
|
|
||||||
"language2": "언어 2",
|
|
||||||
"enterLanguageName": "언어 이름을 입력하세요",
|
|
||||||
"edit": "편집",
|
|
||||||
"delete": "삭제"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "언어 학습",
|
|
||||||
"description": "인공 언어를 포함하여 세상의 거의 모든 언어를 배우는 데 도움이 되는 매우 유용한 웹사이트입니다.",
|
|
||||||
"explore": "탐색",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— 스티브 잡스"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "번역기",
|
|
||||||
"description": "모든 언어로 번역하고 국제 음성 기호(IPA)로 주석 추가"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "텍스트 스피커",
|
|
||||||
"description": "텍스트를 인식하고 읽어줍니다. 반복 재생 및 속도 조정 지원"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "SRT 비디오 플레이어",
|
|
||||||
"description": "SRT 자막 파일을 기반으로 문장별로 비디오를 재생하여 원어민 발음 모방"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "알파벳",
|
|
||||||
"description": "알파벳부터 새로운 언어 학습 시작"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "암기",
|
|
||||||
"description": "언어 A에서 언어 B로, 언어 B에서 언어 A로, 받아쓰기 지원"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "사전",
|
|
||||||
"description": "단어와 구문을 조회하고 자세한 정의와 예제 제공"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "더 많은 기능",
|
|
||||||
"description": "개발 중, 기대해 주세요"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "인증",
|
|
||||||
"signIn": "로그인",
|
|
||||||
"signUp": "회원가입",
|
|
||||||
"email": "이메일",
|
|
||||||
"password": "비밀번호",
|
|
||||||
"confirmPassword": "비밀번호 확인",
|
|
||||||
"name": "이름",
|
|
||||||
"signInButton": "로그인",
|
|
||||||
"signUpButton": "회원가입",
|
|
||||||
"noAccount": "계정이 없으신가요?",
|
|
||||||
"hasAccount": "이미 계정이 있으신가요?",
|
|
||||||
"signInWithGitHub": "GitHub로 로그인",
|
|
||||||
"signUpWithGitHub": "GitHub로 회원가입",
|
|
||||||
"invalidEmail": "유효한 이메일 주소를 입력하세요",
|
|
||||||
"passwordTooShort": "비밀번호는 최소 8자 이상이어야 합니다",
|
|
||||||
"passwordsNotMatch": "비밀번호가 일치하지 않습니다",
|
|
||||||
"nameRequired": "이름을 입력하세요",
|
|
||||||
"emailRequired": "이메일을 입력하세요",
|
|
||||||
"passwordRequired": "비밀번호를 입력하세요",
|
|
||||||
"confirmPasswordRequired": "비밀번호 확인을 입력하세요",
|
|
||||||
"loading": "로딩 중..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "폴더 선택",
|
|
||||||
"noFolders": "폴더를 찾을 수 없습니다",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "정답",
|
|
||||||
"next": "다음",
|
|
||||||
"reverse": "반대",
|
|
||||||
"dictation": "받아쓰기",
|
|
||||||
"noTextPairs": "사용 가능한 텍스트 쌍이 없습니다",
|
|
||||||
"disorder": "무작위",
|
|
||||||
"previous": "이전"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "이 폴더에 액세스할 권한이 없습니다"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "learn-languages",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "로그인",
|
|
||||||
"profile": "프로필",
|
|
||||||
"folders": "폴더"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "내 프로필",
|
|
||||||
"email": "이메일: {email}",
|
|
||||||
"logout": "로그아웃"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "비디오 업로드",
|
|
||||||
"uploadSubtitle": "자막 업로드",
|
|
||||||
"pause": "일시정지",
|
|
||||||
"play": "재생",
|
|
||||||
"previous": "이전",
|
|
||||||
"next": "다음",
|
|
||||||
"restart": "처음부터",
|
|
||||||
"autoPause": "자동 일시정지 ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "비디오와 자막 파일을 업로드하세요",
|
|
||||||
"uploadVideoFile": "비디오 파일을 업로드하세요",
|
|
||||||
"uploadSubtitleFile": "자막 파일을 업로드하세요",
|
|
||||||
"processingSubtitle": "자막 파일 처리 중...",
|
|
||||||
"needBothFiles": "학습을 시작하려면 비디오와 자막 파일이 모두 필요합니다",
|
|
||||||
"videoFile": "비디오 파일",
|
|
||||||
"subtitleFile": "자막 파일",
|
|
||||||
"uploaded": "업로드됨",
|
|
||||||
"notUploaded": "업로드되지 않음",
|
|
||||||
"upload": "업로드",
|
|
||||||
"autoPauseStatus": "자동 일시정지: {enabled}",
|
|
||||||
"on": "켜기",
|
|
||||||
"off": "끄기",
|
|
||||||
"videoUploadFailed": "비디오 업로드 실패",
|
|
||||||
"subtitleUploadFailed": "자막 업로드 실패"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "IPA 생성",
|
|
||||||
"viewSavedItems": "저장된 항목 보기",
|
|
||||||
"confirmDeleteAll": "정말 모두 삭제하시겠습니까? (Y/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "언어 감지",
|
|
||||||
"generateIPA": "IPA 생성",
|
|
||||||
"translateInto": "번역",
|
|
||||||
"chinese": "중국어",
|
|
||||||
"english": "영어",
|
|
||||||
"italian": "이탈리아어",
|
|
||||||
"other": "기타",
|
|
||||||
"translating": "번역 중...",
|
|
||||||
"translate": "번역",
|
|
||||||
"inputLanguage": "언어를 입력하세요.",
|
|
||||||
"history": "기록",
|
|
||||||
"enterLanguage": "언어 입력",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "인증되지 않았습니다",
|
|
||||||
"chooseFolder": "추가할 폴더 선택",
|
|
||||||
"noFolders": "폴더를 찾을 수 없습니다",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "닫기",
|
|
||||||
"success": "텍스트 쌍을 폴더에 추가했습니다",
|
|
||||||
"error": "텍스트 쌍 추가 실패"
|
|
||||||
},
|
|
||||||
"autoSave": "자동 저장"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "사전",
|
|
||||||
"description": "상세한 정의와 예제로 단어 및 구문 검색",
|
|
||||||
"searchPlaceholder": "검색할 단어나 구문을 입력하세요...",
|
|
||||||
"searching": "검색 중...",
|
|
||||||
"search": "검색",
|
|
||||||
"languageSettings": "언어 설정",
|
|
||||||
"queryLanguage": "쿼리 언어",
|
|
||||||
"queryLanguageHint": "검색하려는 단어/구문의 언어",
|
|
||||||
"definitionLanguage": "정의 언어",
|
|
||||||
"definitionLanguageHint": "정의를 표시할 언어",
|
|
||||||
"otherLanguagePlaceholder": "또는 다른 언어를 입력하세요...",
|
|
||||||
"currentSettings": "현재 설정: 쿼리 {queryLang}, 정의 {definitionLang}",
|
|
||||||
"relookup": "재검색",
|
|
||||||
"saveToFolder": "폴더에 저장",
|
|
||||||
"loading": "로드 중...",
|
|
||||||
"noResults": "결과를 찾을 수 없습니다",
|
|
||||||
"tryOtherWords": "다른 단어나 구문을 시도하세요",
|
|
||||||
"welcomeTitle": "사전에 오신 것을 환영합니다",
|
|
||||||
"welcomeHint": "위 검색 상자에 단어나 구문을 입력하여 검색을 시작하세요",
|
|
||||||
"lookupFailed": "검색 실패, 나중에 다시 시도하세요",
|
|
||||||
"relookupSuccess": "재검색했습니다",
|
|
||||||
"relookupFailed": "사전 재검색 실패",
|
|
||||||
"pleaseLogin": "먼저 로그인하세요",
|
|
||||||
"pleaseCreateFolder": "먼저 폴더를 만드세요",
|
|
||||||
"savedToFolder": "폴더에 저장됨: {folderName}",
|
|
||||||
"saveFailed": "저장 실패, 나중에 다시 시도하세요"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "ئۆگىنەرلىك ھەرپلەرنى تاللاڭ",
|
|
||||||
"japanese": "ياپونىيە كانا",
|
|
||||||
"english": "ئىنگلىز ئېلىپبې",
|
|
||||||
"uyghur": "ئۇيغۇر ئېلىپبېسى",
|
|
||||||
"esperanto": "ئېسپېرانتو ئېلىپبېسى",
|
|
||||||
"loading": "چىقىرىۋېتىلىۋاتىدۇ...",
|
|
||||||
"loadFailed": "چىقىرىش مەغلۇب بولدى، قايتا سىناڭ",
|
|
||||||
"hideLetter": "ھەرپنى يوشۇرۇش",
|
|
||||||
"showLetter": "ھەرپنى كۆرسىتىش",
|
|
||||||
"hideIPA": "IPA نى يوشۇرۇش",
|
|
||||||
"showIPA": "IPA نى كۆرسىتىش",
|
|
||||||
"roman": "روماللاشتۇرۇش",
|
|
||||||
"letter": "ھەرپ",
|
|
||||||
"random": "ئىختىيارىي ھالەت",
|
|
||||||
"randomNext": "ئىختىيارىي كېيىنكى"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "قىسقۇچلار",
|
|
||||||
"subtitle": "توپلىمىڭىزنى باشقۇرۇڭ",
|
|
||||||
"newFolder": "يېڭى قىسقۇچ",
|
|
||||||
"creating": "قۇرۇۋاتىدۇ...",
|
|
||||||
"noFoldersYet": "قىسقۇچ يوق",
|
|
||||||
"folderInfo": "كود: {id} • {totalPairs} جۈپ",
|
|
||||||
"enterFolderName": "قىسقۇچ نامىنى كىرگۈزۈڭ:",
|
|
||||||
"confirmDelete": "ئۆچۈرۈش ئۈچۈن «{name}» نى كىرگۈزۈڭ:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "سىز بۇ قىسقۇچنىڭ ئىگىسى ئەمەس",
|
|
||||||
"back": "كەينىگە",
|
|
||||||
"textPairs": "تېكىست جۈپلىرى",
|
|
||||||
"itemsCount": "{count} تۈر",
|
|
||||||
"memorize": "ئەستە ساقلاش",
|
|
||||||
"loadingTextPairs": "تېكىست جۈپلىرى چىقىرىۋېتىلىۋاتىدۇ...",
|
|
||||||
"noTextPairs": "بۇ قىسقۇچتا تېكىست جۈپى يوق",
|
|
||||||
"addNewTextPair": "يېڭى تېكىست جۈپى قوشۇڭ",
|
|
||||||
"add": "قوشۇش",
|
|
||||||
"updateTextPair": "تېكىست جۈپىنى يېڭىلاڭ",
|
|
||||||
"update": "يېڭىلاش",
|
|
||||||
"text1": "تېكىست 1",
|
|
||||||
"text2": "تېكىست 2",
|
|
||||||
"language1": "تىل 1",
|
|
||||||
"language2": "تىل 2",
|
|
||||||
"enterLanguageName": "تىل نامىنى كىرگۈزۈڭ",
|
|
||||||
"edit": "تەھرىرلەش",
|
|
||||||
"delete": "ئۆچۈرۈش"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "تىل ئۆگىنىڭ",
|
|
||||||
"description": "بۇ سىزنى دۇنيادىكى ھەممە تىلنى، جۈملىدىن سۈنئىي تىللارنىمۇ ئۆگىنىشىڭىزغا ياردەم بېرىدىغان ناھايىتى پايدىلىق تور بېكەت.",
|
|
||||||
"explore": "ئىزدىنىش",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "Stay hungry, stay foolish.",
|
|
||||||
"author": "— ستىۋ جوۋبس"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "تەرجىمە",
|
|
||||||
"description": "خالىغان تىلغا تەرجىمە قىلىپ خەلقئارالىق فونېتىك ئېلىپبې (IPA) بىلەن ئىزاھاتلاش"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "تېكىست ئوقۇغۇچى",
|
|
||||||
"description": "تېكىستنى پەرقلەندۈرۈپ ئوقىيدۇ، دەۋرىي ئوقۇش ۋە سۈرئەت تەڭشەشنى قوللايدۇ"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "SRT سىن ئوپىراتورى",
|
|
||||||
"description": "SRT خەت ئاستى فايلى ئاساسىدا سىننى جۈملە-جۈملە قويۇپ، يەرلىك ئىخچام ئاۋازنى ئىمتىلايدۇ"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "ئېلىپبې",
|
|
||||||
"description": "ئېلىپبېدىن يېڭى تىل ئۆگىنىشنى باشلاڭ"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "ئەستە ساقلاش",
|
|
||||||
"description": "تىل A دىن تىل غا، تىل B دىن تىل A غا، دىكتات قوللايدۇ"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "لۇغەت",
|
|
||||||
"description": "سۆز ۋە سۆزنى ئىزدەپ، تەپسىلىي ئىزاھات ۋە مىساللار بىلەن تەمىنلەيدۇ"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "تېخىمۇ كۆپ ئىقتىدار",
|
|
||||||
"description": "ئىشلەۋاتىدۇ، كۈتكۈن بولۇڭ"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "دەلىللەش",
|
|
||||||
"signIn": "كىرىش",
|
|
||||||
"signUp": "تىزىملىتىش",
|
|
||||||
"email": "ئېلخەت",
|
|
||||||
"password": "ئىم",
|
|
||||||
"confirmPassword": "ئىمنى جەزملەش",
|
|
||||||
"name": "نام",
|
|
||||||
"signInButton": "كىرىش",
|
|
||||||
"signUpButton": "تىزىملىتىش",
|
|
||||||
"noAccount": "ھېساباتىڭىز يوقمۇ؟",
|
|
||||||
"hasAccount": "ھېساباتىڭىز بارمۇ؟",
|
|
||||||
"signInWithGitHub": "GitHub بىلەن كىرىڭ",
|
|
||||||
"signUpWithGitHub": "GitHub بىلەن تىزىملىتىڭ",
|
|
||||||
"invalidEmail": "ئىناۋەتلىك ئېلخەت ئادرېسى كىرگۈزۈڭ",
|
|
||||||
"passwordTooShort": "ئىم كەم دېگەندە 8 ھەرپتىن تۇرۇشى كېرەك",
|
|
||||||
"passwordsNotMatch": "ئىم ماس كەلمەيدۇ",
|
|
||||||
"nameRequired": "نامىڭىزنى كىرگۈزۈڭ",
|
|
||||||
"emailRequired": "ئېلخىتىڭىزنى كىرگۈزۈڭ",
|
|
||||||
"passwordRequired": "ئىمىڭىزنى كىرگۈزۈڭ",
|
|
||||||
"confirmPasswordRequired": "ئىمىڭىزنى جەزملەڭ",
|
|
||||||
"loading": "چىقىرىۋېتىلىۋاتىدۇ..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "قىسقۇچ تاللاڭ",
|
|
||||||
"noFolders": "قىسقۇچ تېپىلمىدى",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "جاۋاب",
|
|
||||||
"next": "كېيىنكى",
|
|
||||||
"reverse": "تەتۈر",
|
|
||||||
"dictation": "دىكتات",
|
|
||||||
"noTextPairs": "ئىشلەتكىلى بولىدىغان تېكىست جۈپى يوق",
|
|
||||||
"disorder": "بەت ئارلاش",
|
|
||||||
"previous": "ئىلگىرىكى"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "بۇ قىسقۇچنى زىيارەت قىلىشقا ھوقۇقىڭىز يوق"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "تىل ئۆگىنىش",
|
|
||||||
"sourceCode": "GitHub",
|
|
||||||
"sign_in": "كىرىش",
|
|
||||||
"profile": "پروفىل",
|
|
||||||
"folders": "قىسقۇچلار"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "مېنىڭ پروفىلىم",
|
|
||||||
"email": "ئېلخەت: {email}",
|
|
||||||
"logout": "چىقىش"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"uploadVideo": "سىن يۈكلەڭ",
|
|
||||||
"uploadSubtitle": "خەت ئاستى يۈكلەڭ",
|
|
||||||
"pause": "ۋاقىتلىق توختىتىش",
|
|
||||||
"play": "قويۇش",
|
|
||||||
"previous": "ئىلگىرىكى",
|
|
||||||
"next": "كېيىنكى",
|
|
||||||
"restart": "قايتا باشلاش",
|
|
||||||
"autoPause": "ئاپتوماتىك توختىتىش ({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "سىن ھەم خەت ئاستى فايلىنى يۈكلەڭ",
|
|
||||||
"uploadVideoFile": "سىن فايلى يۈكلەڭ",
|
|
||||||
"uploadSubtitleFile": "خەت ئاستى فايلى يۈكلەڭ",
|
|
||||||
"processingSubtitle": "خەت ئاستى فايلى بىر تەرەپ قىلىۋاتىدۇ...",
|
|
||||||
"needBothFiles": "ئۆگىنىشنى باشلاش ئۈچۈن سىن ھەم خەت ئاستى فايلىنىڭ ھەممىسى لازىم",
|
|
||||||
"videoFile": "سىن فايلى",
|
|
||||||
"subtitleFile": "خەت ئاستى فايلى",
|
|
||||||
"uploaded": "يۈكلەندى",
|
|
||||||
"notUploaded": "يۈكلەنمىدى",
|
|
||||||
"upload": "يۈكلەش",
|
|
||||||
"autoPauseStatus": "ئاپتوماتىك توختىتىش: {enabled}",
|
|
||||||
"on": "ئوچۇق",
|
|
||||||
"off": "تاقاق",
|
|
||||||
"videoUploadFailed": "سىن يۈكلەش مەغلۇب بولدى",
|
|
||||||
"subtitleUploadFailed": "خەت ئاستى يۈكلەش مەغلۇب بولدى"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "IPA ھاسىل قىلىش",
|
|
||||||
"viewSavedItems": "ساقلانغان تۈرلەرنى كۆرۈش",
|
|
||||||
"confirmDeleteAll": "ھەممىنى ئۆچۈرەمسىز؟ (H/Y)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "تىل پەرقلەندۈرۈش",
|
|
||||||
"generateIPA": "IPA ھاسىل قىلىش",
|
|
||||||
"translateInto": "تەرجىمە قىلىش",
|
|
||||||
"chinese": "خەنزۇچە",
|
|
||||||
"english": "ئىنگلىزچە",
|
|
||||||
"italian": "ئىتاليانچە",
|
|
||||||
"other": "باشقا",
|
|
||||||
"translating": "تەرجىمە قىلىۋاتىدۇ...",
|
|
||||||
"translate": "تەرجىمە قىلىش",
|
|
||||||
"inputLanguage": "بىر تىل كىرگۈزۈڭ.",
|
|
||||||
"history": "تارىخ",
|
|
||||||
"enterLanguage": "تىل كىرگۈزۈڭ",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "دەلىتلەنمىدىڭىز",
|
|
||||||
"chooseFolder": "قوشۇلىدىغان قىسقۇچنى تاللاڭ",
|
|
||||||
"noFolders": "قىسقۇچ تېپىلمىدى",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "تاقاش",
|
|
||||||
"success": "تېكىست جۈپى قىسقۇچقا قوشۇلدى",
|
|
||||||
"error": "تېكىست جۈپىنى قىسقۇچقا قوشۇش مەغلۇب بولدى"
|
|
||||||
},
|
|
||||||
"autoSave": "ئاپتوماتىك ساقلاش"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "لۇغەت",
|
|
||||||
"description": "تەپسىلىي ئىلمىيى ۋە مىساللار بىلەن سۆز ۋە ئىبارە ئىزدەش",
|
|
||||||
"searchPlaceholder": "ئىزدەيدىغان سۆز ياكى ئىبارە كىرگۈزۈڭ...",
|
|
||||||
"searching": "ئىزدەۋاتىدۇ...",
|
|
||||||
"search": "ئىزدە",
|
|
||||||
"languageSettings": "تىل تەڭشىكى",
|
|
||||||
"queryLanguage": "سۈرەشتۈرۈش تىلى",
|
|
||||||
"queryLanguageHint": "ئىزدەمدەكچى بولغان سۆز/ئىبارە قايسى تىلدا",
|
|
||||||
"definitionLanguage": "ئىلمىيى تىلى",
|
|
||||||
"definitionLanguageHint": "ئىلمىيىنى قايسى تىلدا كۆرۈشنى ئويلىشىسىز",
|
|
||||||
"otherLanguagePlaceholder": "ياكى باشقا تىل كىرگۈزۈڭ...",
|
|
||||||
"currentSettings": "نۆۋەتتىكى تەڭشەك: سۈرەشتۈرۈش {queryLang}، ئىلمىيى {definitionLang}",
|
|
||||||
"relookup": "قايتا ئىزدە",
|
|
||||||
"saveToFolder": "قىسقۇچقا ساقلا",
|
|
||||||
"loading": "يۈكلىۋاتىدۇ...",
|
|
||||||
"noResults": "نەتىجە تېپىلمىدى",
|
|
||||||
"tryOtherWords": "باشقا سۆز ياكى ئىبارە سىناڭ",
|
|
||||||
"welcomeTitle": "لۇغەتكە مەرھەمەت",
|
|
||||||
"welcomeHint": "ئىزدەشنى باشلاش ئۈچۈن يۇقىرىدىكى ئىزدەش رامكىسىغا سۆز ياكى ئىبارە كىرگۈزۈڭ",
|
|
||||||
"lookupFailed": "ئىزدەش مەغلۇب بولدى، كېيىنرەك قايتا سىناڭ",
|
|
||||||
"relookupSuccess": "مۇۋەپپەقىيەتلىك قايتا ئىزدىدى",
|
|
||||||
"relookupFailed": "لۇغەت قايتا ئىزدىشى مەغلۇب بولدى",
|
|
||||||
"pleaseLogin": "ئاۋۋال تىزىملىتىڭ",
|
|
||||||
"pleaseCreateFolder": "ئاۋۋال قىسقۇچ قۇرۇڭ",
|
|
||||||
"savedToFolder": "قىسقۇچقا ساقلاندى: {folderName}",
|
|
||||||
"saveFailed": "ساقلاش مەغلۇب بولدى، كېيىنرەك قايتا سىناڭ"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
{
|
|
||||||
"alphabet": {
|
|
||||||
"chooseCharacters": "请选择您想学习的字符",
|
|
||||||
"japanese": "日语假名",
|
|
||||||
"english": "英文字母",
|
|
||||||
"uyghur": "维吾尔字母",
|
|
||||||
"esperanto": "世界语字母",
|
|
||||||
"loading": "加载中...",
|
|
||||||
"loadFailed": "加载失败,请重试",
|
|
||||||
"hideLetter": "隐藏字母",
|
|
||||||
"showLetter": "显示字母",
|
|
||||||
"hideIPA": "隐藏IPA",
|
|
||||||
"showIPA": "显示IPA",
|
|
||||||
"roman": "罗马音",
|
|
||||||
"letter": "字母",
|
|
||||||
"random": "随机模式",
|
|
||||||
"randomNext": "随机下一个"
|
|
||||||
},
|
|
||||||
"folders": {
|
|
||||||
"title": "文件夹",
|
|
||||||
"subtitle": "管理您的集合",
|
|
||||||
"newFolder": "新建文件夹",
|
|
||||||
"creating": "创建中...",
|
|
||||||
"noFoldersYet": "还没有文件夹",
|
|
||||||
"folderInfo": "ID: {id} • {totalPairs} 个文本对",
|
|
||||||
"enterFolderName": "输入文件夹名称:",
|
|
||||||
"confirmDelete": "输入 \"{name}\" 以删除:"
|
|
||||||
},
|
|
||||||
"folder_id": {
|
|
||||||
"unauthorized": "您不是此文件夹的所有者",
|
|
||||||
"back": "返回",
|
|
||||||
"textPairs": "文本对",
|
|
||||||
"itemsCount": "{count} 个项目",
|
|
||||||
"memorize": "记忆",
|
|
||||||
"loadingTextPairs": "加载文本对中...",
|
|
||||||
"noTextPairs": "此文件夹中没有文本对",
|
|
||||||
"addNewTextPair": "添加新文本对",
|
|
||||||
"add": "添加",
|
|
||||||
"updateTextPair": "更新文本对",
|
|
||||||
"update": "更新",
|
|
||||||
"text1": "文本1",
|
|
||||||
"text2": "文本2",
|
|
||||||
"language1": "语言1",
|
|
||||||
"language2": "语言2",
|
|
||||||
"enterLanguageName": "请输入语言名称",
|
|
||||||
"edit": "编辑",
|
|
||||||
"delete": "删除"
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"title": "学语言",
|
|
||||||
"description": "这里是一个非常有用的网站,可以帮助您学习世界上几乎每一种语言,包括人造语言。",
|
|
||||||
"explore": "探索网站",
|
|
||||||
"fortune": {
|
|
||||||
"quote": "求知若饥,虚心若愚。",
|
|
||||||
"author": "—— 史蒂夫·乔布斯"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"name": "翻译器",
|
|
||||||
"description": "翻译到任何语言,并标注国际音标(IPA)"
|
|
||||||
},
|
|
||||||
"textSpeaker": {
|
|
||||||
"name": "朗读器",
|
|
||||||
"description": "识别并朗读文本,支持循环朗读、朗读速度调节"
|
|
||||||
},
|
|
||||||
"srtPlayer": {
|
|
||||||
"name": "逐句放视频",
|
|
||||||
"description": "基于SRT字幕文件,逐句播放视频以模仿母语者的发音"
|
|
||||||
},
|
|
||||||
"alphabet": {
|
|
||||||
"name": "字母表",
|
|
||||||
"description": "从字母表开始新语言的学习"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"name": "记忆",
|
|
||||||
"description": "语言A到语言B,语言B到语言A,支持听写"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"name": "词典",
|
|
||||||
"description": "查询单词和短语,提供详细的释义和例句"
|
|
||||||
},
|
|
||||||
"moreFeatures": {
|
|
||||||
"name": "更多功能",
|
|
||||||
"description": "开发中,敬请期待"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"auth": {
|
|
||||||
"title": "登录",
|
|
||||||
"signIn": "登录",
|
|
||||||
"signUp": "注册",
|
|
||||||
"email": "邮箱",
|
|
||||||
"password": "密码",
|
|
||||||
"confirmPassword": "确认密码",
|
|
||||||
"name": "用户名",
|
|
||||||
"signInButton": "登录",
|
|
||||||
"signUpButton": "注册",
|
|
||||||
"noAccount": "还没有账户?",
|
|
||||||
"hasAccount": "已有账户?",
|
|
||||||
"signInWithGitHub": "使用 GitHub 登录",
|
|
||||||
"signUpWithGitHub": "使用 GitHub 注册",
|
|
||||||
"invalidEmail": "请输入有效的邮箱地址",
|
|
||||||
"passwordTooShort": "密码至少需要8个字符",
|
|
||||||
"passwordsNotMatch": "两次输入的密码不匹配",
|
|
||||||
"nameRequired": "请输入用户名",
|
|
||||||
"emailRequired": "请输入邮箱",
|
|
||||||
"passwordRequired": "请输入密码",
|
|
||||||
"confirmPasswordRequired": "请确认密码",
|
|
||||||
"loading": "加载中..."
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"folder_selector": {
|
|
||||||
"selectFolder": "选择文件夹",
|
|
||||||
"noFolders": "未找到文件夹",
|
|
||||||
"folderInfo": "{id}. {name} ({count})"
|
|
||||||
},
|
|
||||||
"memorize": {
|
|
||||||
"answer": "答案",
|
|
||||||
"next": "下一个",
|
|
||||||
"reverse": "反向",
|
|
||||||
"dictation": "听写",
|
|
||||||
"noTextPairs": "没有可用的文本对",
|
|
||||||
"disorder": "乱序",
|
|
||||||
"previous": "上一个"
|
|
||||||
},
|
|
||||||
"page": {
|
|
||||||
"unauthorized": "您无权访问该文件夹"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"navbar": {
|
|
||||||
"title": "学语言",
|
|
||||||
"sourceCode": "源码",
|
|
||||||
"sign_in": "登录",
|
|
||||||
"profile": "个人资料",
|
|
||||||
"folders": "文件夹"
|
|
||||||
},
|
|
||||||
"profile": {
|
|
||||||
"myProfile": "我的个人资料",
|
|
||||||
"email": "邮箱:{email}",
|
|
||||||
"logout": "退出登录"
|
|
||||||
},
|
|
||||||
"srt_player": {
|
|
||||||
"upload": "上传",
|
|
||||||
"uploadVideo": "上传视频",
|
|
||||||
"uploadSubtitle": "上传字幕",
|
|
||||||
"pause": "暂停",
|
|
||||||
"play": "播放",
|
|
||||||
"previous": "上句",
|
|
||||||
"next": "下句",
|
|
||||||
"restart": "句首",
|
|
||||||
"autoPause": "自动暂停({enabled})",
|
|
||||||
"uploadVideoAndSubtitle": "请上传视频和字幕文件",
|
|
||||||
"uploadVideoFile": "请上传视频文件",
|
|
||||||
"uploadSubtitleFile": "请上传字幕文件",
|
|
||||||
"processingSubtitle": "字幕文件正在处理中...",
|
|
||||||
"needBothFiles": "需要同时上传视频和字幕文件才能开始学习",
|
|
||||||
"videoFile": "视频文件",
|
|
||||||
"subtitleFile": "字幕文件",
|
|
||||||
"uploaded": "已上传",
|
|
||||||
"notUploaded": "未上传",
|
|
||||||
"autoPauseStatus": "自动暂停: {enabled}",
|
|
||||||
"on": "开",
|
|
||||||
"off": "关",
|
|
||||||
"videoUploadFailed": "视频上传失败",
|
|
||||||
"subtitleUploadFailed": "字幕上传失败"
|
|
||||||
},
|
|
||||||
"text_speaker": {
|
|
||||||
"generateIPA": "生成IPA",
|
|
||||||
"viewSavedItems": "查看保存项",
|
|
||||||
"confirmDeleteAll": "确定删光吗?(Y/N)"
|
|
||||||
},
|
|
||||||
"translator": {
|
|
||||||
"detectLanguage": "检测语言",
|
|
||||||
"generateIPA": "生成国际音标",
|
|
||||||
"translateInto": "翻译为",
|
|
||||||
"chinese": "中文",
|
|
||||||
"english": "英文",
|
|
||||||
"italian": "意大利语",
|
|
||||||
"other": "其他",
|
|
||||||
"translating": "翻译中...",
|
|
||||||
"translate": "翻译",
|
|
||||||
"inputLanguage": "请输入语言。",
|
|
||||||
"history": "历史记录",
|
|
||||||
"enterLanguage": "输入语言",
|
|
||||||
"add_to_folder": {
|
|
||||||
"notAuthenticated": "您未通过身份验证",
|
|
||||||
"chooseFolder": "选择要添加到的文件夹",
|
|
||||||
"noFolders": "未找到文件夹",
|
|
||||||
"folderInfo": "{id}. {name}",
|
|
||||||
"close": "关闭",
|
|
||||||
"success": "文本对已添加到文件夹",
|
|
||||||
"error": "添加文本对到文件夹失败"
|
|
||||||
},
|
|
||||||
"autoSave": "自动保存"
|
|
||||||
},
|
|
||||||
"dictionary": {
|
|
||||||
"title": "词典",
|
|
||||||
"description": "查询单词和短语,提供详细的释义和例句",
|
|
||||||
"searchPlaceholder": "输入要查询的单词或短语...",
|
|
||||||
"searching": "查询中...",
|
|
||||||
"search": "查询",
|
|
||||||
"languageSettings": "语言设置",
|
|
||||||
"queryLanguage": "查询语言",
|
|
||||||
"queryLanguageHint": "你要查询的单词/短语是什么语言",
|
|
||||||
"definitionLanguage": "释义语言",
|
|
||||||
"definitionLanguageHint": "你希望用什么语言查看释义",
|
|
||||||
"otherLanguagePlaceholder": "或输入其他语言...",
|
|
||||||
"currentSettings": "当前设置:查询 {queryLang},释义 {definitionLang}",
|
|
||||||
"relookup": "重新查询",
|
|
||||||
"saveToFolder": "保存到文件夹",
|
|
||||||
"loading": "加载中...",
|
|
||||||
"noResults": "未找到结果",
|
|
||||||
"tryOtherWords": "尝试其他单词或短语",
|
|
||||||
"welcomeTitle": "欢迎使用词典",
|
|
||||||
"welcomeHint": "在上方搜索框中输入单词或短语开始查询",
|
|
||||||
"lookupFailed": "查询失败,请稍后重试",
|
|
||||||
"relookupSuccess": "已重新查询",
|
|
||||||
"relookupFailed": "词典重新查询失败",
|
|
||||||
"pleaseLogin": "请先登录",
|
|
||||||
"pleaseCreateFolder": "请先创建文件夹",
|
|
||||||
"savedToFolder": "已保存到文件夹:{folderName}",
|
|
||||||
"saveFailed": "保存失败,请稍后重试"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
reactCompiler: true
|
|
||||||
// allowedDevOrigins: ["192.168.3.65", "192.168.3.66"],
|
// allowedDevOrigins: ["192.168.3.65", "192.168.3.66"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
15872
package-lock.json
generated
Normal file
15872
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
60
package.json
60
package.json
@@ -3,53 +3,35 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --experimental-https",
|
"dev": "next dev --turbopack",
|
||||||
"build": "next build",
|
"build": "next build --turbopack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/adapter-pg": "^7.2.0",
|
|
||||||
"@prisma/client": "^7.2.0",
|
|
||||||
"bcryptjs": "^3.0.3",
|
"bcryptjs": "^3.0.3",
|
||||||
"better-auth": "^1.4.10",
|
"edge-tts-universal": "^1.3.2",
|
||||||
"dotenv": "^17.2.3",
|
"next": "15.5.3",
|
||||||
"lucide-react": "^0.562.0",
|
"next-auth": "^4.24.13",
|
||||||
"next": "16.1.1",
|
"next-intl": "^4.4.0",
|
||||||
"next-intl": "^4.7.0",
|
|
||||||
"pg": "^8.16.3",
|
"pg": "^8.16.3",
|
||||||
"react": "19.2.3",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.2.3",
|
"react-dom": "19.1.0",
|
||||||
"sonner": "^2.0.7",
|
"unstorage": "^1.17.2",
|
||||||
"unstorage": "^1.17.3",
|
"zod": "^3.25.76"
|
||||||
"zod": "^4.3.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@better-auth/cli": "^1.4.10",
|
"@eslint/eslintrc": "^3",
|
||||||
"@eslint/eslintrc": "^3.3.3",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@tailwindcss/postcss": "^4.1.18",
|
"@types/bcryptjs": "^2.4.6",
|
||||||
"@types/node": "^25.0.3",
|
"@types/node": "^20",
|
||||||
"@types/react": "19.2.7",
|
"@types/pg": "^8.15.6",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react": "^19",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
"@types/react-dom": "^19",
|
||||||
"@typescript-eslint/parser": "^8.51.0",
|
"eslint": "^9",
|
||||||
"babel-plugin-react-compiler": "^1.0.0",
|
"eslint-config-next": "15.5.3",
|
||||||
"eslint": "^9.39.2",
|
"tailwindcss": "^4",
|
||||||
"eslint-config-next": "16.1.1",
|
"typescript": "^5"
|
||||||
"eslint-plugin-react": "^7.37.5",
|
|
||||||
"prisma": "^7.2.0",
|
|
||||||
"tailwindcss": "^4.1.18",
|
|
||||||
"typescript": "^5.9.3"
|
|
||||||
},
|
|
||||||
"pnpm": {
|
|
||||||
"overrides": {
|
|
||||||
"@types/react": "19.2.7",
|
|
||||||
"@types/react-dom": "19.2.3"
|
|
||||||
},
|
|
||||||
"ignoredBuiltDependencies": [
|
|
||||||
"@prisma/client"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6657
pnpm-lock.yaml
generated
6657
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
|||||||
import { defineConfig, env } from "prisma/config";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
schema: "prisma/schema.prisma",
|
|
||||||
migrations: {
|
|
||||||
path: "prisma/migrations",
|
|
||||||
},
|
|
||||||
datasource: {
|
|
||||||
url: env("DATABASE_URL"),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE "pairs" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"locale1" VARCHAR(10) NOT NULL,
|
|
||||||
"locale2" VARCHAR(10) NOT NULL,
|
|
||||||
"text1" TEXT NOT NULL,
|
|
||||||
"text2" TEXT NOT NULL,
|
|
||||||
"ipa1" TEXT,
|
|
||||||
"ipa2" TEXT,
|
|
||||||
"folder_id" INTEGER NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "pairs_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "folders" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"user_id" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "folders_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "user" (
|
|
||||||
"id" TEXT NOT NULL,
|
|
||||||
"name" TEXT NOT NULL,
|
|
||||||
"email" TEXT NOT NULL,
|
|
||||||
"emailVerified" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"image" TEXT,
|
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "session" (
|
|
||||||
"id" TEXT NOT NULL,
|
|
||||||
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
"token" TEXT NOT NULL,
|
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
"ipAddress" TEXT,
|
|
||||||
"userAgent" TEXT,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "session_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "account" (
|
|
||||||
"id" TEXT NOT NULL,
|
|
||||||
"accountId" TEXT NOT NULL,
|
|
||||||
"providerId" TEXT NOT NULL,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"accessToken" TEXT,
|
|
||||||
"refreshToken" TEXT,
|
|
||||||
"idToken" TEXT,
|
|
||||||
"accessTokenExpiresAt" TIMESTAMP(3),
|
|
||||||
"refreshTokenExpiresAt" TIMESTAMP(3),
|
|
||||||
"scope" TEXT,
|
|
||||||
"password" TEXT,
|
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "account_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "verification" (
|
|
||||||
"id" TEXT NOT NULL,
|
|
||||||
"identifier" TEXT NOT NULL,
|
|
||||||
"value" TEXT NOT NULL,
|
|
||||||
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "verification_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "pairs_folder_id_idx" ON "pairs"("folder_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "pairs_folder_id_locale1_locale2_text1_key" ON "pairs"("folder_id", "locale1", "locale2", "text1");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "folders_user_id_idx" ON "folders"("user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "session_userId_idx" ON "session"("userId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "account_userId_idx" ON "account"("userId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "pairs" ADD CONSTRAINT "pairs_folder_id_fkey" FOREIGN KEY ("folder_id") REFERENCES "folders"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "folders" ADD CONSTRAINT "folders_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `ipa1` on the `pairs` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the column `ipa2` on the `pairs` table. All the data in the column will be lost.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
-- 重命名并修改类型为 TEXT
|
|
||||||
ALTER TABLE "pairs"
|
|
||||||
RENAME COLUMN "locale1" TO "language1";
|
|
||||||
|
|
||||||
ALTER TABLE "pairs"
|
|
||||||
ALTER COLUMN "language1" SET DATA TYPE VARCHAR(20);
|
|
||||||
|
|
||||||
ALTER TABLE "pairs"
|
|
||||||
RENAME COLUMN "locale2" TO "language2";
|
|
||||||
|
|
||||||
ALTER TABLE "pairs"
|
|
||||||
ALTER COLUMN "language2" SET DATA TYPE VARCHAR(20);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "dictionary_lookups" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"user_id" TEXT,
|
|
||||||
"text" TEXT NOT NULL,
|
|
||||||
"query_lang" TEXT NOT NULL,
|
|
||||||
"definition_lang" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"dictionary_word_id" INTEGER,
|
|
||||||
"dictionary_phrase_id" INTEGER,
|
|
||||||
|
|
||||||
CONSTRAINT "dictionary_lookups_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "dictionary_words" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"standard_form" TEXT NOT NULL,
|
|
||||||
"query_lang" TEXT NOT NULL,
|
|
||||||
"definition_lang" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "dictionary_words_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "dictionary_phrases" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"standard_form" TEXT NOT NULL,
|
|
||||||
"query_lang" TEXT NOT NULL,
|
|
||||||
"definition_lang" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "dictionary_phrases_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "dictionary_word_entries" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"word_id" INTEGER NOT NULL,
|
|
||||||
"ipa" TEXT NOT NULL,
|
|
||||||
"definition" TEXT NOT NULL,
|
|
||||||
"part_of_speech" TEXT NOT NULL,
|
|
||||||
"example" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "dictionary_word_entries_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "dictionary_phrase_entries" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"phrase_id" INTEGER NOT NULL,
|
|
||||||
"definition" TEXT NOT NULL,
|
|
||||||
"example" TEXT NOT NULL,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "dictionary_phrase_entries_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_lookups_user_id_idx" ON "dictionary_lookups"("user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_lookups_created_at_idx" ON "dictionary_lookups"("created_at");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_lookups_text_query_lang_definition_lang_idx" ON "dictionary_lookups"("text", "query_lang", "definition_lang");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_words_standard_form_idx" ON "dictionary_words"("standard_form");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_words_query_lang_definition_lang_idx" ON "dictionary_words"("query_lang", "definition_lang");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "dictionary_words_standard_form_query_lang_definition_lang_key" ON "dictionary_words"("standard_form", "query_lang", "definition_lang");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_phrases_standard_form_idx" ON "dictionary_phrases"("standard_form");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_phrases_query_lang_definition_lang_idx" ON "dictionary_phrases"("query_lang", "definition_lang");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "dictionary_phrases_standard_form_query_lang_definition_lang_key" ON "dictionary_phrases"("standard_form", "query_lang", "definition_lang");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_word_entries_word_id_idx" ON "dictionary_word_entries"("word_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_word_entries_created_at_idx" ON "dictionary_word_entries"("created_at");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_phrase_entries_phrase_id_idx" ON "dictionary_phrase_entries"("phrase_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "dictionary_phrase_entries_created_at_idx" ON "dictionary_phrase_entries"("created_at");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "dictionary_lookups" ADD CONSTRAINT "dictionary_lookups_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "dictionary_lookups" ADD CONSTRAINT "dictionary_lookups_dictionary_word_id_fkey" FOREIGN KEY ("dictionary_word_id") REFERENCES "dictionary_words"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "dictionary_lookups" ADD CONSTRAINT "dictionary_lookups_dictionary_phrase_id_fkey" FOREIGN KEY ("dictionary_phrase_id") REFERENCES "dictionary_phrases"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "dictionary_word_entries" ADD CONSTRAINT "dictionary_word_entries_word_id_fkey" FOREIGN KEY ("word_id") REFERENCES "dictionary_words"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "dictionary_phrase_entries" ADD CONSTRAINT "dictionary_phrase_entries_phrase_id_fkey" FOREIGN KEY ("phrase_id") REFERENCES "dictionary_phrases"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
-- DropIndex
|
|
||||||
DROP INDEX "dictionary_phrases_standard_form_query_lang_definition_lang_key";
|
|
||||||
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "dictionary_words_standard_form_query_lang_definition_lang_key";
|
|
||||||
|
|
||||||
-- RenameIndex
|
|
||||||
ALTER INDEX "pairs_folder_id_locale1_locale2_text1_key" RENAME TO "pairs_folder_id_language1_language2_text1_key";
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE "translation_history" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"user_id" TEXT,
|
|
||||||
"source_text" TEXT NOT NULL,
|
|
||||||
"source_language" VARCHAR(20) NOT NULL,
|
|
||||||
"target_language" VARCHAR(20) NOT NULL,
|
|
||||||
"translated_text" TEXT NOT NULL,
|
|
||||||
"source_ipa" TEXT,
|
|
||||||
"target_ipa" TEXT,
|
|
||||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "translation_history_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "translation_history_user_id_idx" ON "translation_history"("user_id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "translation_history_created_at_idx" ON "translation_history"("created_at");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "translation_history_source_text_target_language_idx" ON "translation_history"("source_text", "target_language");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "translation_history_translated_text_source_language_target__idx" ON "translation_history"("translated_text", "source_language", "target_language");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "translation_history" ADD CONSTRAINT "translation_history_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- A unique constraint covering the columns `[folder_id,language1,language2,text1,text2]` on the table `pairs` will be added. If there are existing duplicate values, this will fail.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "pairs_folder_id_language1_language2_text1_key";
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "pairs_folder_id_language1_language2_text1_text2_key" ON "pairs"("folder_id", "language1", "language2", "text1", "text2");
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Please do not edit this file manually
|
|
||||||
# It should be added in your version-control system (e.g., Git)
|
|
||||||
provider = "postgresql"
|
|
||||||
@@ -1,212 +0,0 @@
|
|||||||
generator client {
|
|
||||||
provider = "prisma-client"
|
|
||||||
output = "../generated/prisma"
|
|
||||||
}
|
|
||||||
|
|
||||||
datasource db {
|
|
||||||
provider = "postgresql"
|
|
||||||
}
|
|
||||||
|
|
||||||
model User {
|
|
||||||
id String @id
|
|
||||||
name String
|
|
||||||
email String
|
|
||||||
emailVerified Boolean @default(false)
|
|
||||||
image String?
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
sessions Session[]
|
|
||||||
accounts Account[]
|
|
||||||
folders Folder[]
|
|
||||||
dictionaryLookUps DictionaryLookUp[]
|
|
||||||
translationHistories TranslationHistory[]
|
|
||||||
|
|
||||||
@@unique([email])
|
|
||||||
@@map("user")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Session {
|
|
||||||
id String @id
|
|
||||||
expiresAt DateTime
|
|
||||||
token String
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
ipAddress String?
|
|
||||||
userAgent String?
|
|
||||||
userId String
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@unique([token])
|
|
||||||
@@index([userId])
|
|
||||||
@@map("session")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Account {
|
|
||||||
id String @id
|
|
||||||
accountId String
|
|
||||||
providerId String
|
|
||||||
userId String
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
accessToken String?
|
|
||||||
refreshToken String?
|
|
||||||
idToken String?
|
|
||||||
accessTokenExpiresAt DateTime?
|
|
||||||
refreshTokenExpiresAt DateTime?
|
|
||||||
scope String?
|
|
||||||
password String?
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
|
|
||||||
@@index([userId])
|
|
||||||
@@map("account")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Verification {
|
|
||||||
id String @id
|
|
||||||
identifier String
|
|
||||||
value String
|
|
||||||
expiresAt DateTime
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
|
|
||||||
@@index([identifier])
|
|
||||||
@@map("verification")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Pair {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
text1 String
|
|
||||||
text2 String
|
|
||||||
language1 String @db.VarChar(20)
|
|
||||||
language2 String @db.VarChar(20)
|
|
||||||
ipa1 String?
|
|
||||||
ipa2 String?
|
|
||||||
folderId Int @map("folder_id")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
folder Folder @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@unique([folderId, language1, language2, text1, text2])
|
|
||||||
@@index([folderId])
|
|
||||||
@@map("pairs")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Folder {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
name String
|
|
||||||
userId String @map("user_id")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
pairs Pair[]
|
|
||||||
|
|
||||||
@@index([userId])
|
|
||||||
@@map("folders")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryLookUp {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
userId String? @map("user_id")
|
|
||||||
text String
|
|
||||||
queryLang String @map("query_lang")
|
|
||||||
definitionLang String @map("definition_lang")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
dictionaryWordId Int? @map("dictionary_word_id")
|
|
||||||
dictionaryPhraseId Int? @map("dictionary_phrase_id")
|
|
||||||
|
|
||||||
user User? @relation(fields: [userId], references: [id])
|
|
||||||
dictionaryWord DictionaryWord? @relation(fields: [dictionaryWordId], references: [id], onDelete: SetNull)
|
|
||||||
dictionaryPhrase DictionaryPhrase? @relation(fields: [dictionaryPhraseId], references: [id], onDelete: SetNull)
|
|
||||||
|
|
||||||
@@index([userId])
|
|
||||||
@@index([createdAt])
|
|
||||||
@@index([text, queryLang, definitionLang])
|
|
||||||
@@map("dictionary_lookups")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryWord {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
standardForm String @map("standard_form")
|
|
||||||
queryLang String @map("query_lang")
|
|
||||||
definitionLang String @map("definition_lang")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
lookups DictionaryLookUp[]
|
|
||||||
entries DictionaryWordEntry[]
|
|
||||||
|
|
||||||
@@index([standardForm])
|
|
||||||
@@index([queryLang, definitionLang])
|
|
||||||
@@map("dictionary_words")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryPhrase {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
standardForm String @map("standard_form")
|
|
||||||
queryLang String @map("query_lang")
|
|
||||||
definitionLang String @map("definition_lang")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
lookups DictionaryLookUp[]
|
|
||||||
entries DictionaryPhraseEntry[]
|
|
||||||
|
|
||||||
@@index([standardForm])
|
|
||||||
@@index([queryLang, definitionLang])
|
|
||||||
@@map("dictionary_phrases")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryWordEntry {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
wordId Int @map("word_id")
|
|
||||||
ipa String
|
|
||||||
definition String
|
|
||||||
partOfSpeech String @map("part_of_speech")
|
|
||||||
example String
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
word DictionaryWord @relation(fields: [wordId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@index([wordId])
|
|
||||||
@@index([createdAt])
|
|
||||||
@@map("dictionary_word_entries")
|
|
||||||
}
|
|
||||||
|
|
||||||
model DictionaryPhraseEntry {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
phraseId Int @map("phrase_id")
|
|
||||||
definition String
|
|
||||||
example String
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
phrase DictionaryPhrase @relation(fields: [phraseId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@index([phraseId])
|
|
||||||
@@index([createdAt])
|
|
||||||
@@map("dictionary_phrase_entries")
|
|
||||||
}
|
|
||||||
|
|
||||||
model TranslationHistory {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
userId String? @map("user_id")
|
|
||||||
sourceText String @map("source_text")
|
|
||||||
sourceLanguage String @map("source_language") @db.VarChar(20)
|
|
||||||
targetLanguage String @map("target_language") @db.VarChar(20)
|
|
||||||
translatedText String @map("translated_text")
|
|
||||||
sourceIpa String? @map("source_ipa")
|
|
||||||
targetIpa String? @map("target_ipa")
|
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
|
||||||
|
|
||||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
|
||||||
|
|
||||||
@@index([userId])
|
|
||||||
@@index([createdAt])
|
|
||||||
@@index([sourceText, targetLanguage])
|
|
||||||
@@index([translatedText, sourceLanguage, targetLanguage])
|
|
||||||
@@map("translation_history")
|
|
||||||
}
|
|
||||||
11
public/changelog.txt
Normal file
11
public/changelog.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
2025.11.10 重构了translator,将其改为并发请求多个数据,速度大大提升
|
||||||
|
2025.10.31 添加国际化支持
|
||||||
|
2025.10.30 添加背单词功能
|
||||||
|
2025.10.12 添加朗读器本地保存功能
|
||||||
|
2025.10.09 新增记忆字母表功能
|
||||||
|
2025.10.08 加快了TTS的生成速度,将IPA生成设置为可选项
|
||||||
|
2025.10.07 新增文本朗读器,优化了视频播放器UI
|
||||||
|
2025.10.06 更新了主页面UI,移除IPA生成与文本朗读功能,新增全语言翻译器
|
||||||
|
2025.10.05 新增IPA生成与文本朗读功能
|
||||||
|
2025.09.25 优化了主界面UI
|
||||||
|
2025.09.19 更新了单词板,单词不再会重叠
|
||||||
Binary file not shown.
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="180.425mm"
|
|
||||||
height="66.658363mm"
|
|
||||||
viewBox="0 0 180.425 66.658363"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<defs
|
|
||||||
id="defs1" />
|
|
||||||
<g
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(-19.117989,-118.50376)">
|
|
||||||
<rect
|
|
||||||
style="fill:#00ccff;stroke-width:4.38923"
|
|
||||||
id="rect1"
|
|
||||||
width="180.42502"
|
|
||||||
height="66.658356"
|
|
||||||
x="19.117989"
|
|
||||||
y="118.50375" />
|
|
||||||
<text
|
|
||||||
xml:space="preserve"
|
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:52.6706px;font-family:'Noto Serif';-inkscape-font-specification:'Noto Serif';text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#f2f2f2;stroke-width:4.38923"
|
|
||||||
x="29.942305"
|
|
||||||
y="167.45377"
|
|
||||||
id="text1"
|
|
||||||
transform="scale(0.98306332,1.0172285)"><tspan
|
|
||||||
id="tspan1"
|
|
||||||
style="fill:#f2f2f2;stroke-width:4.38923"
|
|
||||||
x="29.942305"
|
|
||||||
y="167.45377">Learn!</tspan></text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
13
public/messages/en-US/alphabet.json
Normal file
13
public/messages/en-US/alphabet.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"chooseCharacters": "Please select the characters you want to learn",
|
||||||
|
"japanese": "Japanese Kana",
|
||||||
|
"english": "English Alphabet",
|
||||||
|
"uyghur": "Uyghur Alphabet",
|
||||||
|
"esperanto": "Esperanto Alphabet",
|
||||||
|
"loading": "Loading...",
|
||||||
|
"loadFailed": "Loading failed, please try again",
|
||||||
|
"hideLetter": "Hide Letter",
|
||||||
|
"showLetter": "Show Letter",
|
||||||
|
"hideIPA": "Hide IPA",
|
||||||
|
"showIPA": "Show IPA"
|
||||||
|
}
|
||||||
33
public/messages/en-US/home.json
Normal file
33
public/messages/en-US/home.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"title": "Learn Languages",
|
||||||
|
"description": "Here is a very useful website to help you learn almost every language in the world, including constructed ones.",
|
||||||
|
"explore": "Explore",
|
||||||
|
"fortune": {
|
||||||
|
"quote": "Stay hungry, stay foolish.",
|
||||||
|
"author": "— Steve Jobs"
|
||||||
|
},
|
||||||
|
"translator": {
|
||||||
|
"name": "Translator",
|
||||||
|
"description": "Translate to any language and annotate with International Phonetic Alphabet (IPA)"
|
||||||
|
},
|
||||||
|
"textSpeaker": {
|
||||||
|
"name": "Text Speaker",
|
||||||
|
"description": "Recognize and read text aloud, supports loop playback and speed adjustment"
|
||||||
|
},
|
||||||
|
"srtPlayer": {
|
||||||
|
"name": "SRT Video Player",
|
||||||
|
"description": "Play videos sentence by sentence based on SRT subtitle files to mimic native speaker pronunciation"
|
||||||
|
},
|
||||||
|
"alphabet": {
|
||||||
|
"name": "Memorize Alphabet",
|
||||||
|
"description": "Start learning a new language from the alphabet"
|
||||||
|
},
|
||||||
|
"memorize": {
|
||||||
|
"name": "Memorize Words",
|
||||||
|
"description": "Language A to Language B, Language B to Language A, supports dictation"
|
||||||
|
},
|
||||||
|
"moreFeatures": {
|
||||||
|
"name": "More Features",
|
||||||
|
"description": "Under development, stay tuned"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
public/messages/en-US/memorize/choose.json
Normal file
4
public/messages/en-US/memorize/choose.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"back": "Back",
|
||||||
|
"choose": "Choose"
|
||||||
|
}
|
||||||
6
public/messages/en-US/memorize/edit.json
Normal file
6
public/messages/en-US/memorize/edit.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"back": "Back",
|
||||||
|
"save": "Save Word Pairs",
|
||||||
|
"locale1": "Locale 1",
|
||||||
|
"locale2": "Locale 2"
|
||||||
|
}
|
||||||
10
public/messages/en-US/memorize/main.json
Normal file
10
public/messages/en-US/memorize/main.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"title": "Memorize",
|
||||||
|
"locale1": "Your selected locale 1 is {locale}",
|
||||||
|
"locale2": "Your selected locale 2 is {locale}",
|
||||||
|
"total": "There are {total} word pairs in total",
|
||||||
|
"start": "Start",
|
||||||
|
"import": "Import",
|
||||||
|
"export": "Export",
|
||||||
|
"edit": "Edit"
|
||||||
|
}
|
||||||
7
public/messages/en-US/memorize/start.json
Normal file
7
public/messages/en-US/memorize/start.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"show": "Show",
|
||||||
|
"reverse": "Reverse",
|
||||||
|
"dictation": "Dictation",
|
||||||
|
"back": "Back",
|
||||||
|
"next": "Next"
|
||||||
|
}
|
||||||
7
public/messages/en-US/navbar.json
Normal file
7
public/messages/en-US/navbar.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"title": "LL",
|
||||||
|
"about": "About",
|
||||||
|
"sourceCode": "GitHub",
|
||||||
|
"login": "Login",
|
||||||
|
"profile": "Profile"
|
||||||
|
}
|
||||||
10
public/messages/en-US/srt-player.json
Normal file
10
public/messages/en-US/srt-player.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"uploadVideo": "Upload Video",
|
||||||
|
"uploadSubtitle": "Upload Subtitle",
|
||||||
|
"pause": "Pause",
|
||||||
|
"play": "Play",
|
||||||
|
"previous": "Previous",
|
||||||
|
"next": "Next",
|
||||||
|
"restart": "Restart",
|
||||||
|
"autoPause": "Auto Pause ({enabled})"
|
||||||
|
}
|
||||||
5
public/messages/en-US/text-speaker.json
Normal file
5
public/messages/en-US/text-speaker.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"generateIPA": "Generate IPA",
|
||||||
|
"viewSavedItems": "View Saved Items",
|
||||||
|
"confirmDeleteAll": "Are you sure you want to delete everything? (Y/N)"
|
||||||
|
}
|
||||||
12
public/messages/en-US/translator.json
Normal file
12
public/messages/en-US/translator.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"detectLanguage": "detect language",
|
||||||
|
"generateIPA": "generate ipa",
|
||||||
|
"translateInto": "translate into",
|
||||||
|
"chinese": "Chinese",
|
||||||
|
"english": "English",
|
||||||
|
"italian": "Italian",
|
||||||
|
"other": "Other",
|
||||||
|
"translating": "translating...",
|
||||||
|
"translate": "translate",
|
||||||
|
"inputLanguage": "Input a language."
|
||||||
|
}
|
||||||
13
public/messages/zh-CN/alphabet.json
Normal file
13
public/messages/zh-CN/alphabet.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"chooseCharacters": "请选择您想学习的字符",
|
||||||
|
"japanese": "日语假名",
|
||||||
|
"english": "英文字母",
|
||||||
|
"uyghur": "维吾尔字母",
|
||||||
|
"esperanto": "世界语字母",
|
||||||
|
"loading": "加载中...",
|
||||||
|
"loadFailed": "加载失败,请重试",
|
||||||
|
"hideLetter": "隐藏字母",
|
||||||
|
"showLetter": "显示字母",
|
||||||
|
"hideIPA": "隐藏IPA",
|
||||||
|
"showIPA": "显示IPA"
|
||||||
|
}
|
||||||
33
public/messages/zh-CN/home.json
Normal file
33
public/messages/zh-CN/home.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"title": "学语言",
|
||||||
|
"description": "这里是一个非常有用的网站,可以帮助你学习世界上几乎每一种语言,包括人造语言。",
|
||||||
|
"explore": "探索网站",
|
||||||
|
"fortune": {
|
||||||
|
"quote": "求知若饥,虚心若愚。",
|
||||||
|
"author": "—— 史蒂夫·乔布斯"
|
||||||
|
},
|
||||||
|
"translator": {
|
||||||
|
"name": "翻译器",
|
||||||
|
"description": "翻译到任何语言,并标注国际音标(IPA)"
|
||||||
|
},
|
||||||
|
"textSpeaker": {
|
||||||
|
"name": "朗读器",
|
||||||
|
"description": "识别并朗读文本,支持循环朗读、朗读速度调节"
|
||||||
|
},
|
||||||
|
"srtPlayer": {
|
||||||
|
"name": "逐句视频播放器",
|
||||||
|
"description": "基于SRT字幕文件,逐句播放视频以模仿母语者的发音"
|
||||||
|
},
|
||||||
|
"alphabet": {
|
||||||
|
"name": "背字母",
|
||||||
|
"description": "从字母表开始新语言的学习"
|
||||||
|
},
|
||||||
|
"memorize": {
|
||||||
|
"name": "背单词",
|
||||||
|
"description": "语言A到语言B,语言B到语言A,支持听写"
|
||||||
|
},
|
||||||
|
"moreFeatures": {
|
||||||
|
"name": "更多功能",
|
||||||
|
"description": "开发中,敬请期待"
|
||||||
|
}
|
||||||
|
}
|
||||||
4
public/messages/zh-CN/memorize/choose.json
Normal file
4
public/messages/zh-CN/memorize/choose.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"back": "返回",
|
||||||
|
"choose": "选择"
|
||||||
|
}
|
||||||
6
public/messages/zh-CN/memorize/edit.json
Normal file
6
public/messages/zh-CN/memorize/edit.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"back": "返回",
|
||||||
|
"save": "保存单词对",
|
||||||
|
"locale1": "区域1",
|
||||||
|
"locale2": "区域2"
|
||||||
|
}
|
||||||
10
public/messages/zh-CN/memorize/main.json
Normal file
10
public/messages/zh-CN/memorize/main.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"title": "记忆",
|
||||||
|
"locale1": "您选择的区域一是{locale}",
|
||||||
|
"locale2": "您选择的区域二是{locale}",
|
||||||
|
"total": "总计有{total}个单词对",
|
||||||
|
"start": "开始",
|
||||||
|
"import": "导入",
|
||||||
|
"export": "导出",
|
||||||
|
"edit": "编辑"
|
||||||
|
}
|
||||||
7
public/messages/zh-CN/memorize/start.json
Normal file
7
public/messages/zh-CN/memorize/start.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"show": "显示",
|
||||||
|
"reverse": "反向",
|
||||||
|
"dictation": "听写",
|
||||||
|
"back": "返回",
|
||||||
|
"next": "下个"
|
||||||
|
}
|
||||||
7
public/messages/zh-CN/navbar.json
Normal file
7
public/messages/zh-CN/navbar.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"title": "学语言",
|
||||||
|
"about": "关于",
|
||||||
|
"sourceCode": "源码",
|
||||||
|
"login": "登录",
|
||||||
|
"profile": "个人资料"
|
||||||
|
}
|
||||||
10
public/messages/zh-CN/srt-player.json
Normal file
10
public/messages/zh-CN/srt-player.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"uploadVideo": "上传视频",
|
||||||
|
"uploadSubtitle": "上传字幕",
|
||||||
|
"pause": "暂停",
|
||||||
|
"play": "播放",
|
||||||
|
"previous": "上句",
|
||||||
|
"next": "下句",
|
||||||
|
"restart": "句首",
|
||||||
|
"autoPause": "自动暂停({enabled})"
|
||||||
|
}
|
||||||
5
public/messages/zh-CN/text-speaker.json
Normal file
5
public/messages/zh-CN/text-speaker.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"generateIPA": "生成IPA",
|
||||||
|
"viewSavedItems": "查看保存项",
|
||||||
|
"confirmDeleteAll": "确定删光吗?(Y/N)"
|
||||||
|
}
|
||||||
12
public/messages/zh-CN/translator.json
Normal file
12
public/messages/zh-CN/translator.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"detectLanguage": "检测语言",
|
||||||
|
"generateIPA": "生成国际音标",
|
||||||
|
"translateInto": "翻译为",
|
||||||
|
"chinese": "中文",
|
||||||
|
"english": "英文",
|
||||||
|
"italian": "意大利语",
|
||||||
|
"other": "其他",
|
||||||
|
"translating": "翻译中...",
|
||||||
|
"translate": "翻译",
|
||||||
|
"inputLanguage": "请输入语言。"
|
||||||
|
}
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState, useEffect, useCallback } from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { Letter, SupportedAlphabets } from "@/lib/interfaces";
|
|
||||||
import { IconClick } from "@/components/ui/buttons";
|
|
||||||
import IMAGES from "@/config/images";
|
|
||||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
||||||
|
|
||||||
interface AlphabetCardProps {
|
|
||||||
alphabet: Letter[];
|
|
||||||
alphabetType: SupportedAlphabets;
|
|
||||||
onBack: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AlphabetCard({ alphabet, alphabetType, onBack }: AlphabetCardProps) {
|
|
||||||
const t = useTranslations("alphabet");
|
|
||||||
const [currentIndex, setCurrentIndex] = useState(0);
|
|
||||||
const [showIPA, setShowIPA] = useState(true);
|
|
||||||
const [showLetter, setShowLetter] = useState(true);
|
|
||||||
const [showRoman, setShowRoman] = useState(false);
|
|
||||||
const [isRandomMode, setIsRandomMode] = useState(false);
|
|
||||||
|
|
||||||
// 只有日语假名显示罗马音按钮
|
|
||||||
const hasRomanization = alphabetType === "japanese";
|
|
||||||
|
|
||||||
const currentLetter = alphabet[currentIndex];
|
|
||||||
|
|
||||||
|
|
||||||
const goToNext = useCallback(() => {
|
|
||||||
if (isRandomMode) {
|
|
||||||
setCurrentIndex(Math.floor(Math.random() * alphabet.length));
|
|
||||||
} else {
|
|
||||||
setCurrentIndex((prev) => (prev === alphabet.length - 1 ? 0 : prev + 1));
|
|
||||||
}
|
|
||||||
}, [alphabet.length, isRandomMode]);
|
|
||||||
|
|
||||||
const goToPrevious = useCallback(() => {
|
|
||||||
if (isRandomMode) {
|
|
||||||
setCurrentIndex(Math.floor(Math.random() * alphabet.length));
|
|
||||||
} else {
|
|
||||||
setCurrentIndex((prev) => (prev === 0 ? alphabet.length - 1 : prev - 1));
|
|
||||||
}
|
|
||||||
}, [alphabet.length, isRandomMode]);
|
|
||||||
|
|
||||||
const goToRandom = useCallback(() => {
|
|
||||||
setCurrentIndex(Math.floor(Math.random() * alphabet.length));
|
|
||||||
}, [alphabet.length]);
|
|
||||||
|
|
||||||
// 键盘快捷键支持
|
|
||||||
useEffect(() => {
|
|
||||||
const handleKeyDown = (e: globalThis.KeyboardEvent) => {
|
|
||||||
if (e.key === "ArrowLeft") {
|
|
||||||
goToPrevious();
|
|
||||||
} else if (e.key === "ArrowRight") {
|
|
||||||
goToNext();
|
|
||||||
} else if (e.key === " ") {
|
|
||||||
e.preventDefault();
|
|
||||||
goToRandom();
|
|
||||||
} else if (e.key === "Escape") {
|
|
||||||
onBack();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener("keydown", handleKeyDown);
|
|
||||||
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
||||||
}, [goToPrevious, goToNext, goToRandom, onBack]);
|
|
||||||
|
|
||||||
// 触摸滑动支持
|
|
||||||
const [touchStart, setTouchStart] = useState<number | null>(null);
|
|
||||||
const [touchEnd, setTouchEnd] = useState<number | null>(null);
|
|
||||||
|
|
||||||
const minSwipeDistance = 50;
|
|
||||||
|
|
||||||
const onTouchStart = (e: React.TouchEvent) => {
|
|
||||||
setTouchEnd(null);
|
|
||||||
setTouchStart(e.targetTouches[0].clientX);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onTouchMove = (e: React.TouchEvent) => {
|
|
||||||
setTouchEnd(e.targetTouches[0].clientX);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onTouchEnd = () => {
|
|
||||||
if (!touchStart || !touchEnd) return;
|
|
||||||
|
|
||||||
const distance = touchStart - touchEnd;
|
|
||||||
const isLeftSwipe = distance > minSwipeDistance;
|
|
||||||
const isRightSwipe = distance < -minSwipeDistance;
|
|
||||||
|
|
||||||
if (isLeftSwipe) {
|
|
||||||
goToNext();
|
|
||||||
}
|
|
||||||
if (isRightSwipe) {
|
|
||||||
goToPrevious();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center px-4 py-8">
|
|
||||||
<div className="w-full max-w-2xl">
|
|
||||||
{/* 右上角返回按钮 */}
|
|
||||||
<div className="flex justify-end mb-4">
|
|
||||||
<IconClick
|
|
||||||
size={32}
|
|
||||||
alt="close"
|
|
||||||
src={IMAGES.close}
|
|
||||||
onClick={onBack}
|
|
||||||
className="bg-white rounded-full shadow-md"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 白色主卡片容器 */}
|
|
||||||
<div className="bg-white rounded-2xl shadow-xl p-8 md:p-12">
|
|
||||||
{/* 顶部进度指示器和显示选项按钮 */}
|
|
||||||
<div className="flex justify-between items-center mb-6">
|
|
||||||
{/* 当前字母进度 */}
|
|
||||||
<span className="text-sm text-gray-500">
|
|
||||||
{currentIndex + 1} / {alphabet.length}
|
|
||||||
</span>
|
|
||||||
{/* 显示选项切换按钮组 */}
|
|
||||||
<div className="flex gap-2 flex-wrap">
|
|
||||||
<button
|
|
||||||
onClick={() => setShowLetter(!showLetter)}
|
|
||||||
className={`px-3 py-1 rounded-full text-sm transition-colors ${
|
|
||||||
showLetter
|
|
||||||
? "bg-[#35786f] text-white"
|
|
||||||
: "bg-gray-200 text-gray-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("letter")}
|
|
||||||
</button>
|
|
||||||
{/* IPA 音标显示切换 */}
|
|
||||||
<button
|
|
||||||
onClick={() => setShowIPA(!showIPA)}
|
|
||||||
className={`px-3 py-1 rounded-full text-sm transition-colors ${
|
|
||||||
showIPA
|
|
||||||
? "bg-[#35786f] text-white"
|
|
||||||
: "bg-gray-200 text-gray-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
IPA
|
|
||||||
</button>
|
|
||||||
{/* 罗马音显示切换(仅日语显示) */}
|
|
||||||
{hasRomanization && (
|
|
||||||
<button
|
|
||||||
onClick={() => setShowRoman(!showRoman)}
|
|
||||||
className={`px-3 py-1 rounded-full text-sm transition-colors ${
|
|
||||||
showRoman
|
|
||||||
? "bg-[#35786f] text-white"
|
|
||||||
: "bg-gray-200 text-gray-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("roman")}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{/* 随机模式切换 */}
|
|
||||||
<button
|
|
||||||
onClick={() => setIsRandomMode(!isRandomMode)}
|
|
||||||
className={`px-3 py-1 rounded-full text-sm transition-colors ${
|
|
||||||
isRandomMode
|
|
||||||
? "bg-[#35786f] text-white"
|
|
||||||
: "bg-gray-200 text-gray-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("random")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 字母主要内容显示区域 */}
|
|
||||||
<div className="text-center mb-8">
|
|
||||||
{/* 字母本身(可隐藏) */}
|
|
||||||
{showLetter ? (
|
|
||||||
<div className="text-6xl md:text-8xl font-bold text-gray-800 mb-4">
|
|
||||||
{currentLetter.letter}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="text-6xl md:text-8xl font-bold text-gray-300 mb-4 h-20 md:h-24 flex items-center justify-center">
|
|
||||||
<span className="text-2xl md:text-3xl text-gray-400">?</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* IPA 音标显示 */}
|
|
||||||
{showIPA && (
|
|
||||||
<div className="text-2xl md:text-3xl text-gray-600 mb-2">
|
|
||||||
{currentLetter.letter_sound_ipa}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 罗马音显示(日语) */}
|
|
||||||
{showRoman && hasRomanization && currentLetter.roman_letter && (
|
|
||||||
<div className="text-lg md:text-xl text-gray-500">
|
|
||||||
{currentLetter.roman_letter}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 底部导航控制区域 */}
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
{/* 上一个按钮 */}
|
|
||||||
<button
|
|
||||||
onClick={goToPrevious}
|
|
||||||
className="p-3 rounded-full bg-gray-100 hover:bg-gray-200 transition-colors"
|
|
||||||
aria-label="上一个字母"
|
|
||||||
>
|
|
||||||
<ChevronLeft size={24} />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* 中间区域:随机按钮 */}
|
|
||||||
<div className="flex gap-2 items-center">
|
|
||||||
{isRandomMode && (
|
|
||||||
<button
|
|
||||||
onClick={goToRandom}
|
|
||||||
className="px-4 py-2 rounded-full bg-[#35786f] text-white text-sm font-medium hover:bg-[#2d5f58] transition-colors"
|
|
||||||
>
|
|
||||||
{t("randomNext")}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 下一个按钮 */}
|
|
||||||
<button
|
|
||||||
onClick={goToNext}
|
|
||||||
className="p-3 rounded-full bg-gray-100 hover:bg-gray-200 transition-colors"
|
|
||||||
aria-label="下一个字母"
|
|
||||||
>
|
|
||||||
<ChevronRight size={24} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 底部操作提示文字 */}
|
|
||||||
<div className="text-center mt-6 text-white text-sm">
|
|
||||||
<p>
|
|
||||||
{isRandomMode
|
|
||||||
? "使用左右箭头键或空格键随机切换字母,ESC键返回"
|
|
||||||
: "使用左右箭头键或滑动切换字母,ESC键返回"
|
|
||||||
}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 全屏触摸事件监听层(用于滑动切换) */}
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 pointer-events-none"
|
|
||||||
onTouchStart={onTouchStart}
|
|
||||||
onTouchMove={onTouchMove}
|
|
||||||
onTouchEnd={onTouchEnd}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { Letter, SupportedAlphabets } from "@/lib/interfaces";
|
|
||||||
import Container from "@/components/ui/Container";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import AlphabetCard from "./AlphabetCard";
|
|
||||||
|
|
||||||
export default function Alphabet() {
|
|
||||||
const t = useTranslations("alphabet");
|
|
||||||
const [chosenAlphabet, setChosenAlphabet] = useState<SupportedAlphabets | null>(null);
|
|
||||||
const [alphabetData, setAlphabetData] = useState<Letter[] | null>(null);
|
|
||||||
const [loadingState, setLoadingState] = useState<"idle" | "loading" | "success" | "error">("idle");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const loadAlphabetData = async () => {
|
|
||||||
if (chosenAlphabet && !alphabetData) {
|
|
||||||
try {
|
|
||||||
setLoadingState("loading");
|
|
||||||
|
|
||||||
const res = await fetch("/alphabets/" + chosenAlphabet + ".json");
|
|
||||||
if (!res.ok) throw new Error("Network response was not ok");
|
|
||||||
|
|
||||||
const obj = await res.json();
|
|
||||||
setAlphabetData(obj as Letter[]);
|
|
||||||
setLoadingState("success");
|
|
||||||
} catch (error) {
|
|
||||||
setLoadingState("error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadAlphabetData();
|
|
||||||
}, [chosenAlphabet, alphabetData]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (loadingState === "error") {
|
|
||||||
const timer = setTimeout(() => {
|
|
||||||
setLoadingState("idle");
|
|
||||||
setChosenAlphabet(null);
|
|
||||||
setAlphabetData(null);
|
|
||||||
}, 2000);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}
|
|
||||||
}, [loadingState]);
|
|
||||||
|
|
||||||
// 语言选择界面
|
|
||||||
if (!chosenAlphabet) {
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex flex-col items-center justify-center px-4">
|
|
||||||
<Container className="p-8 max-w-2xl w-full text-center">
|
|
||||||
{/* 页面标题 */}
|
|
||||||
<h1 className="text-4xl md:text-5xl font-bold text-gray-800 mb-4">
|
|
||||||
{t("chooseCharacters")}
|
|
||||||
</h1>
|
|
||||||
{/* 副标题说明 */}
|
|
||||||
<p className="text-gray-600 mb-8 text-lg">
|
|
||||||
选择一种语言的字母表开始学习
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{/* 语言选择按钮网格 */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
||||||
{/* 日语假名选项 */}
|
|
||||||
<LightButton
|
|
||||||
onClick={() => setChosenAlphabet("japanese")}
|
|
||||||
className="p-6 text-lg font-medium hover:scale-105 transition-transform"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col items-center">
|
|
||||||
<span className="text-2xl mb-2">あいうえお</span>
|
|
||||||
<span>{t("japanese")}</span>
|
|
||||||
</div>
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
{/* 英语字母选项 */}
|
|
||||||
<LightButton
|
|
||||||
onClick={() => setChosenAlphabet("english")}
|
|
||||||
className="p-6 text-lg font-medium hover:scale-105 transition-transform"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col items-center">
|
|
||||||
<span className="text-2xl mb-2">ABC</span>
|
|
||||||
<span>{t("english")}</span>
|
|
||||||
</div>
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
{/* 维吾尔语字母选项 */}
|
|
||||||
<LightButton
|
|
||||||
onClick={() => setChosenAlphabet("uyghur")}
|
|
||||||
className="p-6 text-lg font-medium hover:scale-105 transition-transform"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col items-center">
|
|
||||||
<span className="text-2xl mb-2">ئۇيغۇر</span>
|
|
||||||
<span>{t("uyghur")}</span>
|
|
||||||
</div>
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
{/* 世界语字母选项 */}
|
|
||||||
<LightButton
|
|
||||||
onClick={() => setChosenAlphabet("esperanto")}
|
|
||||||
className="p-6 text-lg font-medium hover:scale-105 transition-transform"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col items-center">
|
|
||||||
<span className="text-2xl mb-2">ABCĜĤ</span>
|
|
||||||
<span>{t("esperanto")}</span>
|
|
||||||
</div>
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载状态
|
|
||||||
if (loadingState === "loading") {
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center">
|
|
||||||
<Container className="p-8 text-center">
|
|
||||||
<div className="text-2xl text-gray-600">{t("loading")}</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 错误状态
|
|
||||||
if (loadingState === "error") {
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center">
|
|
||||||
<Container className="p-8 text-center">
|
|
||||||
<div className="text-2xl text-red-600">{t("loadFailed")}</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 字母卡片界面
|
|
||||||
if (loadingState === "success" && alphabetData) {
|
|
||||||
return (
|
|
||||||
<AlphabetCard
|
|
||||||
alphabet={alphabetData}
|
|
||||||
alphabetType={chosenAlphabet}
|
|
||||||
onBack={() => {
|
|
||||||
setChosenAlphabet(null);
|
|
||||||
setAlphabetData(null);
|
|
||||||
setLoadingState("idle");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
import { DictWordEntry, DictPhraseEntry } from "./types";
|
|
||||||
|
|
||||||
interface DictionaryEntryProps {
|
|
||||||
entry: DictWordEntry | DictPhraseEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function DictionaryEntry({ entry }: DictionaryEntryProps) {
|
|
||||||
// 检查是否有 ipa 字段来判断是否为单词条目
|
|
||||||
const isWordEntry = "ipa" in entry && "partOfSpeech" in entry;
|
|
||||||
|
|
||||||
if (isWordEntry) {
|
|
||||||
// 单词条目
|
|
||||||
const wordEntry = entry as DictWordEntry;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{/* 音标和词性 */}
|
|
||||||
<div className="flex items-center gap-3 mb-3">
|
|
||||||
{wordEntry.ipa && (
|
|
||||||
<span className="text-gray-600 text-lg">
|
|
||||||
[{wordEntry.ipa}]
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{wordEntry.partOfSpeech && (
|
|
||||||
<span className="px-3 py-1 bg-[#35786f] text-white text-sm rounded-full">
|
|
||||||
{wordEntry.partOfSpeech}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 释义 */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
|
||||||
释义
|
|
||||||
</h3>
|
|
||||||
<p className="text-gray-800">{wordEntry.definition}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 例句 */}
|
|
||||||
{wordEntry.example && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
|
||||||
例句
|
|
||||||
</h3>
|
|
||||||
<p className="text-gray-700 pl-4 border-l-4 border-[#35786f]">
|
|
||||||
{wordEntry.example}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 短语条目
|
|
||||||
const phraseEntry = entry as DictPhraseEntry;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{/* 释义 */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
|
||||||
释义
|
|
||||||
</h3>
|
|
||||||
<p className="text-gray-800">{phraseEntry.definition}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 例句 */}
|
|
||||||
{phraseEntry.example && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-semibold text-gray-700 mb-1">
|
|
||||||
例句
|
|
||||||
</h3>
|
|
||||||
<p className="text-gray-700 pl-4 border-l-4 border-[#35786f]">
|
|
||||||
{phraseEntry.example}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
import Container from "@/components/ui/Container";
|
|
||||||
import { lookUp } from "@/lib/server/bigmodel/dictionaryActions";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import { Folder } from "../../../../generated/prisma/browser";
|
|
||||||
import { getFoldersByUserId } from "@/lib/server/services/folderService";
|
|
||||||
import { DictLookUpResponse, isDictErrorResponse } from "./types";
|
|
||||||
import { SearchForm } from "./SearchForm";
|
|
||||||
import { SearchResult } from "./SearchResult";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { POPULAR_LANGUAGES } from "./constants";
|
|
||||||
|
|
||||||
export default function Dictionary() {
|
|
||||||
const t = useTranslations("dictionary");
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
const [searchResult, setSearchResult] = useState<DictLookUpResponse | null>(null);
|
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
|
||||||
const [hasSearched, setHasSearched] = useState(false);
|
|
||||||
const [queryLang, setQueryLang] = useState("english");
|
|
||||||
const [definitionLang, setDefinitionLang] = useState("chinese");
|
|
||||||
const [selectedFolderId, setSelectedFolderId] = useState<number | null>(null);
|
|
||||||
const [folders, setFolders] = useState<Folder[]>([]);
|
|
||||||
const { data: session } = authClient.useSession();
|
|
||||||
|
|
||||||
// 加载用户的文件夹列表
|
|
||||||
useEffect(() => {
|
|
||||||
if (session) {
|
|
||||||
getFoldersByUserId(session.user.id as string)
|
|
||||||
.then((loadedFolders) => {
|
|
||||||
setFolders(loadedFolders);
|
|
||||||
// 如果有文件夹且未选择,默认选择第一个
|
|
||||||
if (loadedFolders.length > 0 && !selectedFolderId) {
|
|
||||||
setSelectedFolderId(loadedFolders[0].id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [session, selectedFolderId]);
|
|
||||||
|
|
||||||
// 将 code 转换为 nativeName
|
|
||||||
const getNativeName = (code: string) => {
|
|
||||||
return POPULAR_LANGUAGES.find(l => l.code === code)?.nativeName || code;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearch = async (e: React.FormEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
if (!searchQuery.trim()) return;
|
|
||||||
|
|
||||||
setIsSearching(true);
|
|
||||||
setHasSearched(true);
|
|
||||||
setSearchResult(null);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 使用查询语言和释义语言的 nativeName
|
|
||||||
const result = await lookUp({
|
|
||||||
text: searchQuery,
|
|
||||||
definitionLang: getNativeName(definitionLang),
|
|
||||||
queryLang: getNativeName(queryLang),
|
|
||||||
forceRelook: false
|
|
||||||
})
|
|
||||||
|
|
||||||
// 检查是否为错误响应
|
|
||||||
if (isDictErrorResponse(result)) {
|
|
||||||
toast.error(result.error);
|
|
||||||
setSearchResult(null);
|
|
||||||
} else {
|
|
||||||
setSearchResult(result);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("词典查询失败:", error);
|
|
||||||
toast.error(t("lookupFailed"));
|
|
||||||
setSearchResult(null);
|
|
||||||
} finally {
|
|
||||||
setIsSearching(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f]">
|
|
||||||
{/* 搜索区域 */}
|
|
||||||
<div className="flex items-center justify-center px-4 py-12">
|
|
||||||
<Container className="max-w-3xl w-full p-4">
|
|
||||||
<SearchForm
|
|
||||||
searchQuery={searchQuery}
|
|
||||||
onSearchQueryChange={setSearchQuery}
|
|
||||||
isSearching={isSearching}
|
|
||||||
onSearch={handleSearch}
|
|
||||||
queryLang={queryLang}
|
|
||||||
onQueryLangChange={setQueryLang}
|
|
||||||
definitionLang={definitionLang}
|
|
||||||
onDefinitionLangChange={setDefinitionLang}
|
|
||||||
/>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 搜索结果区域 */}
|
|
||||||
<div className="flex-1 px-4 pb-12">
|
|
||||||
<Container className="max-w-3xl w-full p-4">
|
|
||||||
{isSearching && (
|
|
||||||
<div className="text-center py-8">
|
|
||||||
<div className="inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-white"></div>
|
|
||||||
<p className="mt-4 text-white">{t("loading")}</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isSearching && hasSearched && !searchResult && (
|
|
||||||
<div className="text-center py-12 bg-white/20 rounded-lg">
|
|
||||||
<p className="text-gray-800 text-xl">{t("noResults")}</p>
|
|
||||||
<p className="text-gray-600 mt-2">{t("tryOtherWords")}</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isSearching && searchResult && !isDictErrorResponse(searchResult) && (
|
|
||||||
<SearchResult
|
|
||||||
searchResult={searchResult}
|
|
||||||
searchQuery={searchQuery}
|
|
||||||
queryLang={queryLang}
|
|
||||||
definitionLang={definitionLang}
|
|
||||||
folders={folders}
|
|
||||||
selectedFolderId={selectedFolderId}
|
|
||||||
onFolderSelect={setSelectedFolderId}
|
|
||||||
onResultUpdate={setSearchResult}
|
|
||||||
onSearchingChange={setIsSearching}
|
|
||||||
getNativeName={getNativeName}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!hasSearched && (
|
|
||||||
<div className="text-center py-12 bg-white/20 rounded-lg">
|
|
||||||
<div className="text-6xl mb-4">📚</div>
|
|
||||||
<p className="text-gray-800 text-xl mb-2">{t("welcomeTitle")}</p>
|
|
||||||
<p className="text-gray-600">{t("welcomeHint")}</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { POPULAR_LANGUAGES } from "./constants";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
|
|
||||||
interface SearchFormProps {
|
|
||||||
searchQuery: string;
|
|
||||||
onSearchQueryChange: (query: string) => void;
|
|
||||||
isSearching: boolean;
|
|
||||||
onSearch: (e: React.FormEvent) => void;
|
|
||||||
queryLang: string;
|
|
||||||
onQueryLangChange: (lang: string) => void;
|
|
||||||
definitionLang: string;
|
|
||||||
onDefinitionLangChange: (lang: string) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SearchForm({
|
|
||||||
searchQuery,
|
|
||||||
onSearchQueryChange,
|
|
||||||
isSearching,
|
|
||||||
onSearch,
|
|
||||||
queryLang,
|
|
||||||
onQueryLangChange,
|
|
||||||
definitionLang,
|
|
||||||
onDefinitionLangChange,
|
|
||||||
}: SearchFormProps) {
|
|
||||||
const t = useTranslations("dictionary");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{/* 页面标题 */}
|
|
||||||
<div className="text-center mb-8">
|
|
||||||
<h1 className="text-4xl md:text-5xl font-bold text-gray-800 mb-4">
|
|
||||||
{t("title")}
|
|
||||||
</h1>
|
|
||||||
<p className="text-gray-700 text-lg">
|
|
||||||
{t("description")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 搜索表单 */}
|
|
||||||
<form onSubmit={onSearch} className="flex gap-2">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={searchQuery}
|
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => onSearchQueryChange(e.target.value)}
|
|
||||||
placeholder={t("searchPlaceholder")}
|
|
||||||
className="flex-1 px-4 py-3 text-lg text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded"
|
|
||||||
/>
|
|
||||||
<LightButton
|
|
||||||
type="submit"
|
|
||||||
disabled={isSearching || !searchQuery.trim()}
|
|
||||||
className="px-6 py-3"
|
|
||||||
>
|
|
||||||
{isSearching ? t("searching") : t("search")}
|
|
||||||
</LightButton>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{/* 语言设置 */}
|
|
||||||
<div className="mt-4 bg-white/20 rounded-lg p-4">
|
|
||||||
<div className="mb-3">
|
|
||||||
<span className="text-gray-800 font-semibold">{t("languageSettings")}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-4">
|
|
||||||
{/* 查询语言 */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-gray-700 text-sm mb-2">
|
|
||||||
{t("queryLanguage")} ({t("queryLanguageHint")})
|
|
||||||
</label>
|
|
||||||
<div className="flex flex-wrap gap-2 mb-2">
|
|
||||||
{POPULAR_LANGUAGES.map((lang) => (
|
|
||||||
<LightButton
|
|
||||||
key={lang.code}
|
|
||||||
selected={queryLang === lang.code}
|
|
||||||
onClick={() => onQueryLangChange(lang.code)}
|
|
||||||
className="text-sm px-3 py-1"
|
|
||||||
>
|
|
||||||
{lang.nativeName}
|
|
||||||
</LightButton>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={queryLang}
|
|
||||||
onChange={(e) => onQueryLangChange(e.target.value)}
|
|
||||||
placeholder={t("otherLanguagePlaceholder")}
|
|
||||||
className="w-full px-3 py-2 text-sm text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 释义语言 */}
|
|
||||||
<div>
|
|
||||||
<label className="block text-gray-700 text-sm mb-2">
|
|
||||||
{t("definitionLanguage")} ({t("definitionLanguageHint")})
|
|
||||||
</label>
|
|
||||||
<div className="flex flex-wrap gap-2 mb-2">
|
|
||||||
{POPULAR_LANGUAGES.map((lang) => (
|
|
||||||
<LightButton
|
|
||||||
key={lang.code}
|
|
||||||
selected={definitionLang === lang.code}
|
|
||||||
onClick={() => onDefinitionLangChange(lang.code)}
|
|
||||||
className="text-sm px-3 py-1"
|
|
||||||
>
|
|
||||||
{lang.nativeName}
|
|
||||||
</LightButton>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={definitionLang}
|
|
||||||
onChange={(e) => onDefinitionLangChange(e.target.value)}
|
|
||||||
placeholder={t("otherLanguagePlaceholder")}
|
|
||||||
className="w-full px-3 py-2 text-sm text-gray-800 focus:outline-none border-b-2 border-gray-600 bg-white/90 rounded"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 当前设置显示 */}
|
|
||||||
<div className="text-center text-gray-700 text-sm pt-2 border-t border-gray-300">
|
|
||||||
{t("currentSettings", {
|
|
||||||
queryLang: POPULAR_LANGUAGES.find(l => l.code === queryLang)?.nativeName || queryLang,
|
|
||||||
definitionLang: POPULAR_LANGUAGES.find(l => l.code === definitionLang)?.nativeName || definitionLang
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
import { Plus, RefreshCw } from "lucide-react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import { Folder } from "../../../../generated/prisma/browser";
|
|
||||||
import { createPair } from "@/lib/server/services/pairService";
|
|
||||||
import { lookUp } from "@/lib/server/bigmodel/dictionaryActions";
|
|
||||||
import {
|
|
||||||
DictWordResponse,
|
|
||||||
DictPhraseResponse,
|
|
||||||
isDictWordResponse,
|
|
||||||
DictWordEntry,
|
|
||||||
isDictErrorResponse,
|
|
||||||
} from "./types";
|
|
||||||
import { DictionaryEntry } from "./DictionaryEntry";
|
|
||||||
import { POPULAR_LANGUAGES } from "./constants";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
|
|
||||||
interface SearchResultProps {
|
|
||||||
searchResult: DictWordResponse | DictPhraseResponse;
|
|
||||||
searchQuery: string;
|
|
||||||
queryLang: string;
|
|
||||||
definitionLang: string;
|
|
||||||
folders: Folder[];
|
|
||||||
selectedFolderId: number | null;
|
|
||||||
onFolderSelect: (folderId: number | null) => void;
|
|
||||||
onResultUpdate: (newResult: DictWordResponse | DictPhraseResponse) => void;
|
|
||||||
onSearchingChange: (isSearching: boolean) => void;
|
|
||||||
getNativeName: (code: string) => string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SearchResult({
|
|
||||||
searchResult,
|
|
||||||
searchQuery,
|
|
||||||
queryLang,
|
|
||||||
definitionLang,
|
|
||||||
folders,
|
|
||||||
selectedFolderId,
|
|
||||||
onFolderSelect,
|
|
||||||
onResultUpdate,
|
|
||||||
onSearchingChange,
|
|
||||||
getNativeName,
|
|
||||||
}: SearchResultProps) {
|
|
||||||
const t = useTranslations("dictionary");
|
|
||||||
const { data: session } = authClient.useSession();
|
|
||||||
|
|
||||||
const handleRelookup = async () => {
|
|
||||||
onSearchingChange(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await lookUp({
|
|
||||||
text: searchQuery,
|
|
||||||
definitionLang: getNativeName(definitionLang),
|
|
||||||
queryLang: getNativeName(queryLang),
|
|
||||||
forceRelook: true
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isDictErrorResponse(result)) {
|
|
||||||
toast.error(result.error);
|
|
||||||
} else {
|
|
||||||
onResultUpdate(result);
|
|
||||||
toast.success(t("relookupSuccess"));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("词典重新查询失败:", error);
|
|
||||||
toast.error(t("lookupFailed"));
|
|
||||||
} finally {
|
|
||||||
onSearchingChange(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSave = () => {
|
|
||||||
if (!session) {
|
|
||||||
toast.error(t("pleaseLogin"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!selectedFolderId) {
|
|
||||||
toast.error(t("pleaseCreateFolder"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const entry = searchResult.entries[0];
|
|
||||||
createPair({
|
|
||||||
text1: searchResult.standardForm,
|
|
||||||
text2: entry.definition,
|
|
||||||
language1: queryLang,
|
|
||||||
language2: definitionLang,
|
|
||||||
ipa1: isDictWordResponse(searchResult) && (entry as DictWordEntry).ipa ? (entry as DictWordEntry).ipa : undefined,
|
|
||||||
folderId: selectedFolderId,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
const folderName = folders.find(f => f.id === selectedFolderId)?.name || "Unknown";
|
|
||||||
toast.success(t("savedToFolder", { folderName }));
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
toast.error(t("saveFailed"));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-6">
|
|
||||||
<div className="bg-white rounded-lg p-6 shadow-lg">
|
|
||||||
{/* 标题和保存按钮 */}
|
|
||||||
<div className="flex items-start justify-between mb-6">
|
|
||||||
<div className="flex-1">
|
|
||||||
<h2 className="text-3xl font-bold text-gray-800 mb-2">
|
|
||||||
{searchResult.standardForm}
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2 ml-4">
|
|
||||||
{session && folders.length > 0 && (
|
|
||||||
<select
|
|
||||||
value={selectedFolderId || ""}
|
|
||||||
onChange={(e) => onFolderSelect(e.target.value ? Number(e.target.value) : null)}
|
|
||||||
className="px-3 py-2 text-sm border border-gray-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#35786f]"
|
|
||||||
>
|
|
||||||
{folders.map((folder) => (
|
|
||||||
<option key={folder.id} value={folder.id}>
|
|
||||||
{folder.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
)}
|
|
||||||
<button
|
|
||||||
onClick={handleSave}
|
|
||||||
className="hover:bg-gray-200 hover:cursor-pointer rounded-4xl border border-gray-200 w-10 h-10 flex justify-center items-center shrink-0"
|
|
||||||
title={t("saveToFolder")}
|
|
||||||
>
|
|
||||||
<Plus />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 条目列表 */}
|
|
||||||
<div className="space-y-6">
|
|
||||||
{searchResult.entries.map((entry, index) => (
|
|
||||||
<div key={index} className="border-t border-gray-200 pt-4">
|
|
||||||
<DictionaryEntry entry={entry} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 重新查询按钮 */}
|
|
||||||
<div className="border-t border-gray-200 pt-4 mt-4">
|
|
||||||
<button
|
|
||||||
onClick={handleRelookup}
|
|
||||||
className="flex items-center gap-2 px-4 py-2 text-sm text-gray-700 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors"
|
|
||||||
>
|
|
||||||
<RefreshCw className="w-4 h-4" />
|
|
||||||
{t("relookup")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
export const POPULAR_LANGUAGES = [
|
|
||||||
{ code: "english", name: "英语", nativeName: "English" },
|
|
||||||
{ code: "chinese", name: "中文", nativeName: "中文" },
|
|
||||||
{ code: "japanese", name: "日语", nativeName: "日本語" },
|
|
||||||
{ code: "korean", name: "韩语", nativeName: "한국어" },
|
|
||||||
{ code: "italian", name: "意大利语", nativeName: "Italiano" },
|
|
||||||
{ code: "uyghur", name: "维吾尔语", nativeName: "ئۇيغۇرچە" },
|
|
||||||
] as const;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
// 类型定义
|
|
||||||
export * from "./types";
|
|
||||||
|
|
||||||
// 常量
|
|
||||||
export * from "./constants";
|
|
||||||
|
|
||||||
// 组件
|
|
||||||
export { default as DictionaryPage } from "./DictionaryPage";
|
|
||||||
export { SearchForm } from "./SearchForm";
|
|
||||||
export { SearchResult } from "./SearchResult";
|
|
||||||
export { DictionaryEntry } from "./DictionaryEntry";
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from "./DictionaryPage";
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// 从 shared 文件夹导出所有词典类型和类型守卫
|
|
||||||
export * from "@/lib/shared";
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { Folder } from "../../../../generated/prisma/browser";
|
|
||||||
import { Folder as Fd } from "lucide-react";
|
|
||||||
|
|
||||||
interface FolderSelectorProps {
|
|
||||||
folders: (Folder & { total: number })[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const FolderSelector: React.FC<FolderSelectorProps> = ({ folders }) => {
|
|
||||||
const t = useTranslations("memorize.folder_selector");
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center px-4 py-8">
|
|
||||||
<div className="w-full max-w-2xl">
|
|
||||||
<div className="bg-white rounded-2xl shadow-xl p-6 md:p-8">
|
|
||||||
{folders.length === 0 ? (
|
|
||||||
// 空状态 - 显示提示和跳转按钮
|
|
||||||
<div className="text-center">
|
|
||||||
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-4">
|
|
||||||
{t("noFolders")}
|
|
||||||
</h1>
|
|
||||||
<Link
|
|
||||||
className="inline-block px-6 py-2 bg-[#35786f] text-white rounded-full hover:bg-[#2d5f58] transition-colors"
|
|
||||||
href="/folders"
|
|
||||||
>
|
|
||||||
Go to Folders
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{/* 页面标题 */}
|
|
||||||
<h1 className="text-2xl md:text-3xl font-bold text-gray-800 mb-6">
|
|
||||||
{t("selectFolder")}
|
|
||||||
</h1>
|
|
||||||
{/* 文件夹列表 */}
|
|
||||||
<div className="border border-gray-200 rounded-2xl max-h-96 overflow-y-auto">
|
|
||||||
{folders
|
|
||||||
.toSorted((a, b) => a.id - b.id)
|
|
||||||
.map((folder) => (
|
|
||||||
<div
|
|
||||||
key={folder.id}
|
|
||||||
onClick={() =>
|
|
||||||
router.push(`/memorize?folder_id=${folder.id}`)
|
|
||||||
}
|
|
||||||
className="flex flex-row items-center p-4 gap-3 hover:cursor-pointer hover:bg-gray-50 transition-colors border-b border-gray-100 last:border-b-0"
|
|
||||||
>
|
|
||||||
{/* 文件夹图标 */}
|
|
||||||
<div className="flex-shrink-0">
|
|
||||||
<Fd className="text-gray-600" size={24} />
|
|
||||||
</div>
|
|
||||||
{/* 文件夹信息 */}
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="font-medium text-gray-900">
|
|
||||||
{folder.name}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
|
||||||
{t("folderInfo", {
|
|
||||||
id: folder.id,
|
|
||||||
name: folder.name,
|
|
||||||
count: folder.total,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* 右箭头 */}
|
|
||||||
<div className="text-gray-400">
|
|
||||||
<svg
|
|
||||||
className="w-5 h-5"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M9 5l7 7-7 7"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FolderSelector;
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
|
||||||
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/server/bigmodel/tts";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import localFont from "next/font/local";
|
|
||||||
import { isNonNegativeInteger, SeededRandom } from "@/lib/utils";
|
|
||||||
import { Pair } from "../../../../generated/prisma/browser";
|
|
||||||
|
|
||||||
const myFont = localFont({
|
|
||||||
src: "../../../../public/fonts/NotoNaskhArabic-VariableFont_wght.ttf",
|
|
||||||
});
|
|
||||||
|
|
||||||
interface MemorizeProps {
|
|
||||||
textPairs: Pair[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const Memorize: React.FC<MemorizeProps> = ({ textPairs }) => {
|
|
||||||
const t = useTranslations("memorize.memorize");
|
|
||||||
const [reverse, setReverse] = useState(false);
|
|
||||||
const [dictation, setDictation] = useState(false);
|
|
||||||
const [disorder, setDisorder] = useState(false);
|
|
||||||
const [index, setIndex] = useState(0);
|
|
||||||
const [show, setShow] = useState<"question" | "answer">("question");
|
|
||||||
const { load, play } = useAudioPlayer();
|
|
||||||
|
|
||||||
if (textPairs.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center px-4">
|
|
||||||
<div className="bg-white rounded-2xl shadow-xl p-8 max-w-md w-full text-center">
|
|
||||||
<p className="text-gray-700">{t("noTextPairs")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const rng = new SeededRandom(textPairs[0].folderId);
|
|
||||||
const disorderedTextPairs = textPairs.toSorted(() => rng.next() - 0.5);
|
|
||||||
|
|
||||||
textPairs.sort((a, b) => a.id - b.id);
|
|
||||||
|
|
||||||
const getTextPairs = () => disorder ? disorderedTextPairs : textPairs;
|
|
||||||
|
|
||||||
const handleIndexClick = () => {
|
|
||||||
const newIndex = prompt("Input a index number.")?.trim();
|
|
||||||
if (
|
|
||||||
newIndex &&
|
|
||||||
isNonNegativeInteger(newIndex) &&
|
|
||||||
parseInt(newIndex) <= textPairs.length &&
|
|
||||||
parseInt(newIndex) > 0
|
|
||||||
) {
|
|
||||||
setIndex(parseInt(newIndex) - 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNext = async () => {
|
|
||||||
if (show === "answer") {
|
|
||||||
const newIndex = (index + 1) % getTextPairs().length;
|
|
||||||
setIndex(newIndex);
|
|
||||||
if (dictation) {
|
|
||||||
const textPair = getTextPairs()[newIndex];
|
|
||||||
const language = textPair[reverse ? "language2" : "language1"];
|
|
||||||
const text = textPair[reverse ? "text2" : "text1"];
|
|
||||||
|
|
||||||
// 映射语言到 TTS 支持的格式
|
|
||||||
const languageMap: Record<string, TTS_SUPPORTED_LANGUAGES> = {
|
|
||||||
"chinese": "Chinese",
|
|
||||||
"english": "English",
|
|
||||||
"japanese": "Japanese",
|
|
||||||
"korean": "Korean",
|
|
||||||
"french": "French",
|
|
||||||
"german": "German",
|
|
||||||
"italian": "Italian",
|
|
||||||
"portuguese": "Portuguese",
|
|
||||||
"spanish": "Spanish",
|
|
||||||
"russian": "Russian",
|
|
||||||
};
|
|
||||||
|
|
||||||
const ttsLanguage = languageMap[language?.toLowerCase()] || "Auto";
|
|
||||||
|
|
||||||
getTTSUrl(text, ttsLanguage).then((url) => {
|
|
||||||
load(url);
|
|
||||||
play();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setShow(show === "question" ? "answer" : "question");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePrevious = () => {
|
|
||||||
setIndex(
|
|
||||||
(index - 1 + getTextPairs().length) % getTextPairs().length,
|
|
||||||
);
|
|
||||||
setShow("question");
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleReverse = () => setReverse(!reverse);
|
|
||||||
const toggleDictation = () => setDictation(!dictation);
|
|
||||||
const toggleDisorder = () => setDisorder(!disorder);
|
|
||||||
|
|
||||||
const createText = (text: string) => {
|
|
||||||
return (
|
|
||||||
<div className="text-gray-900 text-xl md:text-2xl p-6 h-[20dvh] overflow-y-auto text-center">
|
|
||||||
{text}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const [text1, text2] = reverse
|
|
||||||
? [getTextPairs()[index].text2, getTextPairs()[index].text1]
|
|
||||||
: [getTextPairs()[index].text1, getTextPairs()[index].text2];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-[calc(100vh-64px)] bg-[#35786f] flex items-center justify-center px-4 py-8">
|
|
||||||
<div className="w-full max-w-2xl">
|
|
||||||
<div className="bg-white rounded-2xl shadow-xl p-6 md:p-8">
|
|
||||||
{/* 进度指示器 */}
|
|
||||||
<div className="flex justify-center mb-4">
|
|
||||||
<button
|
|
||||||
onClick={handleIndexClick}
|
|
||||||
className="text-sm text-gray-500 hover:text-gray-700 transition-colors"
|
|
||||||
>
|
|
||||||
{index + 1} / {getTextPairs().length}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 文本显示区域 */}
|
|
||||||
<div className={`h-[40dvh] ${myFont.className} mb-4`}>
|
|
||||||
{(() => {
|
|
||||||
if (dictation) {
|
|
||||||
if (show === "question") {
|
|
||||||
return (
|
|
||||||
<div className="h-full flex items-center justify-center">
|
|
||||||
<div className="text-gray-400 text-4xl">?</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{createText(text1)}
|
|
||||||
<div className="border-t border-gray-200"></div>
|
|
||||||
{createText(text2)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (show === "question") {
|
|
||||||
return createText(text1);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{createText(text1)}
|
|
||||||
<div className="border-t border-gray-200"></div>
|
|
||||||
{createText(text2)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 底部按钮 */}
|
|
||||||
<div className="flex flex-row gap-2 items-center justify-center flex-wrap">
|
|
||||||
<button
|
|
||||||
onClick={handleNext}
|
|
||||||
className="px-4 py-2 rounded-full bg-gray-200 text-gray-700 hover:bg-gray-300 transition-colors text-sm"
|
|
||||||
>
|
|
||||||
{show === "question" ? t("answer") : t("next")}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={handlePrevious}
|
|
||||||
className="px-4 py-2 rounded-full bg-gray-200 text-gray-700 hover:bg-gray-300 transition-colors text-sm"
|
|
||||||
>
|
|
||||||
{t("previous")}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={toggleReverse}
|
|
||||||
className={`px-4 py-2 rounded-full transition-colors text-sm ${
|
|
||||||
reverse
|
|
||||||
? "bg-[#35786f] text-white hover:bg-[#2d5f58]"
|
|
||||||
: "bg-gray-200 text-gray-700 hover:bg-gray-300"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("reverse")}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={toggleDictation}
|
|
||||||
className={`px-4 py-2 rounded-full transition-colors text-sm ${
|
|
||||||
dictation
|
|
||||||
? "bg-[#35786f] text-white hover:bg-[#2d5f58]"
|
|
||||||
: "bg-gray-200 text-gray-700 hover:bg-gray-300"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("dictation")}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={toggleDisorder}
|
|
||||||
className={`px-4 py-2 rounded-full transition-colors text-sm ${
|
|
||||||
disorder
|
|
||||||
? "bg-[#35786f] text-white hover:bg-[#2d5f58]"
|
|
||||||
: "bg-gray-200 text-gray-700 hover:bg-gray-300"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t("disorder")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Memorize;
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { redirect } from "next/navigation";
|
|
||||||
import { getTranslations } from "next-intl/server";
|
|
||||||
import {
|
|
||||||
getFoldersWithTotalPairsByUserId,
|
|
||||||
} from "@/lib/server/services/folderService";
|
|
||||||
import { isNonNegativeInteger } from "@/lib/utils";
|
|
||||||
import FolderSelector from "./FolderSelector";
|
|
||||||
import Memorize from "./Memorize";
|
|
||||||
import { getPairsByFolderId } from "@/lib/server/services/pairService";
|
|
||||||
import { auth } from "@/auth";
|
|
||||||
import { headers } from "next/headers";
|
|
||||||
|
|
||||||
export default async function MemorizePage({
|
|
||||||
searchParams,
|
|
||||||
}: {
|
|
||||||
searchParams: Promise<{ folder_id?: string; }>;
|
|
||||||
}) {
|
|
||||||
const tParam = (await searchParams).folder_id;
|
|
||||||
|
|
||||||
const t = await getTranslations("memorize.page");
|
|
||||||
|
|
||||||
const folder_id = tParam
|
|
||||||
? isNonNegativeInteger(tParam)
|
|
||||||
? parseInt(tParam)
|
|
||||||
: null
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (!folder_id) {
|
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
|
||||||
if(!session) redirect("/auth?redirect=/memorize")
|
|
||||||
return (
|
|
||||||
<FolderSelector
|
|
||||||
folders={await getFoldersWithTotalPairsByUserId(session.user.id)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Memorize textPairs={await getPairsByFolderId(folder_id)} />;
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React, { useRef } from "react";
|
|
||||||
import { FileInputProps } from "../../types/controls";
|
|
||||||
|
|
||||||
interface FileInputComponentProps extends FileInputProps {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function FileInput({ accept, onFileSelect, disabled, className, children }: FileInputComponentProps) {
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
const handleClick = React.useCallback(() => {
|
|
||||||
if (!disabled && inputRef.current) {
|
|
||||||
inputRef.current.click();
|
|
||||||
}
|
|
||||||
}, [disabled]);
|
|
||||||
|
|
||||||
const handleChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const file = event.target.files?.[0];
|
|
||||||
if (file) {
|
|
||||||
onFileSelect(file);
|
|
||||||
}
|
|
||||||
}, [onFileSelect]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
type="file"
|
|
||||||
accept={accept}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={disabled}
|
|
||||||
className="hidden"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
onClick={handleClick}
|
|
||||||
disabled={disabled}
|
|
||||||
className={`px-2 py-1 rounded shadow font-bold hover:cursor-pointer hover:bg-gray-200 text-gray-800 bg-white ${disabled ? 'opacity-50 cursor-not-allowed' : ''} ${className || ''}`}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { PlayButtonProps } from "../../types/player";
|
|
||||||
|
|
||||||
export default function PlayButton({ isPlaying, onToggle, disabled, className }: PlayButtonProps) {
|
|
||||||
const t = useTranslations("srt_player");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : onToggle}
|
|
||||||
disabled={disabled}
|
|
||||||
className={`px-4 py-2 ${className || ''}`}
|
|
||||||
>
|
|
||||||
{isPlaying ? t("pause") : t("play")}
|
|
||||||
</LightButton>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { SeekBarProps } from "../../types/player";
|
|
||||||
|
|
||||||
export default function SeekBar({ value, max, onChange, disabled, className }: SeekBarProps) {
|
|
||||||
const handleChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const newValue = parseInt(event.target.value);
|
|
||||||
onChange(newValue);
|
|
||||||
}, [onChange]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min={0}
|
|
||||||
max={max}
|
|
||||||
value={value}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={disabled}
|
|
||||||
className={`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer ${disabled ? 'opacity-50 cursor-not-allowed' : ''} ${className || ''}`}
|
|
||||||
style={{
|
|
||||||
background: `linear-gradient(to right, #374151 0%, #374151 ${(value / max) * 100}%, #e5e7eb ${(value / max) * 100}%, #e5e7eb 100%)`
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { SpeedControlProps } from "../../types/player";
|
|
||||||
import { getPlaybackRateOptions, getPlaybackRateLabel } from "../../utils/timeUtils";
|
|
||||||
|
|
||||||
export default function SpeedControl({ playbackRate, onPlaybackRateChange, disabled, className }: SpeedControlProps) {
|
|
||||||
const speedOptions = getPlaybackRateOptions();
|
|
||||||
|
|
||||||
const handleSpeedChange = React.useCallback(() => {
|
|
||||||
const currentIndex = speedOptions.indexOf(playbackRate);
|
|
||||||
const nextIndex = (currentIndex + 1) % speedOptions.length;
|
|
||||||
onPlaybackRateChange(speedOptions[nextIndex]);
|
|
||||||
}, [playbackRate, onPlaybackRateChange, speedOptions]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : handleSpeedChange}
|
|
||||||
className={`${disabled ? 'opacity-50 cursor-not-allowed' : ''} ${className || ''}`}
|
|
||||||
>
|
|
||||||
{getPlaybackRateLabel(playbackRate)}
|
|
||||||
</LightButton>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { SubtitleTextProps } from "../../types/subtitle";
|
|
||||||
|
|
||||||
export default function SubtitleText({ text, onWordClick, style, className }: SubtitleTextProps) {
|
|
||||||
const handleWordClick = React.useCallback((word: string) => {
|
|
||||||
onWordClick?.(word);
|
|
||||||
}, [onWordClick]);
|
|
||||||
|
|
||||||
// 将文本分割成单词,保持标点符号
|
|
||||||
const renderTextWithClickableWords = () => {
|
|
||||||
if (!text) return null;
|
|
||||||
|
|
||||||
// 匹配单词和标点符号
|
|
||||||
const parts = text.match(/[\w']+|[^\w\s]+|\s+/g) || [];
|
|
||||||
|
|
||||||
return parts.map((part, index) => {
|
|
||||||
// 如果是单词(字母和撇号组成)
|
|
||||||
if (/^[\w']+$/.test(part)) {
|
|
||||||
return (
|
|
||||||
<span
|
|
||||||
key={index}
|
|
||||||
onClick={() => handleWordClick(part)}
|
|
||||||
className="hover:bg-gray-700 hover:underline hover:cursor-pointer rounded px-1 transition-colors"
|
|
||||||
>
|
|
||||||
{part}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// 如果是空格或其他字符,直接渲染
|
|
||||||
return <span key={index}>{part}</span>;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`overflow-auto h-16 mt-2 wrap-break-words font-sans text-white text-center text-2xl ${className || ''}`}
|
|
||||||
style={style}
|
|
||||||
>
|
|
||||||
{renderTextWithClickableWords()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React, { forwardRef } from "react";
|
|
||||||
import { VideoElementProps } from "../../types/player";
|
|
||||||
|
|
||||||
const VideoElement = forwardRef<HTMLVideoElement, VideoElementProps>(
|
|
||||||
({ src, onTimeUpdate, onLoadedMetadata, onPlay, onPause, onEnded, className }, ref) => {
|
|
||||||
const handleTimeUpdate = React.useCallback((event: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
||||||
const video = event.currentTarget;
|
|
||||||
onTimeUpdate?.(video.currentTime);
|
|
||||||
}, [onTimeUpdate]);
|
|
||||||
|
|
||||||
const handleLoadedMetadata = React.useCallback((event: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
||||||
const video = event.currentTarget;
|
|
||||||
onLoadedMetadata?.(video.duration);
|
|
||||||
}, [onLoadedMetadata]);
|
|
||||||
|
|
||||||
const handlePlay = React.useCallback((event: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
||||||
onPlay?.();
|
|
||||||
}, [onPlay]);
|
|
||||||
|
|
||||||
const handlePause = React.useCallback((event: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
||||||
onPause?.();
|
|
||||||
}, [onPause]);
|
|
||||||
|
|
||||||
const handleEnded = React.useCallback((event: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
||||||
onEnded?.();
|
|
||||||
}, [onEnded]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<video
|
|
||||||
ref={ref}
|
|
||||||
src={src}
|
|
||||||
onTimeUpdate={handleTimeUpdate}
|
|
||||||
onLoadedMetadata={handleLoadedMetadata}
|
|
||||||
onPlay={handlePlay}
|
|
||||||
onPause={handlePause}
|
|
||||||
onEnded={handleEnded}
|
|
||||||
className={`bg-gray-200 w-full ${className || ""}`}
|
|
||||||
playsInline
|
|
||||||
controls={false}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
VideoElement.displayName = "VideoElement";
|
|
||||||
|
|
||||||
export default VideoElement;
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { ChevronLeft, ChevronRight, RotateCcw, Pause } from "lucide-react";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { ControlBarProps } from "../../types/controls";
|
|
||||||
import PlayButton from "../atoms/PlayButton";
|
|
||||||
import SpeedControl from "../atoms/SpeedControl";
|
|
||||||
|
|
||||||
export default function ControlBar({
|
|
||||||
isPlaying,
|
|
||||||
onPlayPause,
|
|
||||||
onPrevious,
|
|
||||||
onNext,
|
|
||||||
onRestart,
|
|
||||||
playbackRate,
|
|
||||||
onPlaybackRateChange,
|
|
||||||
autoPause,
|
|
||||||
onAutoPauseToggle,
|
|
||||||
disabled,
|
|
||||||
className
|
|
||||||
}: ControlBarProps) {
|
|
||||||
const t = useTranslations("srt_player");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex flex-wrap gap-2 justify-center ${className || ''}`}>
|
|
||||||
<PlayButton
|
|
||||||
isPlaying={isPlaying}
|
|
||||||
onToggle={onPlayPause}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : onPrevious}
|
|
||||||
disabled={disabled}
|
|
||||||
className="flex items-center px-3 py-2"
|
|
||||||
>
|
|
||||||
<ChevronLeft className="w-4 h-4 mr-2" />
|
|
||||||
{t("previous")}
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : onNext}
|
|
||||||
disabled={disabled}
|
|
||||||
className="flex items-center px-3 py-2"
|
|
||||||
>
|
|
||||||
{t("next")}
|
|
||||||
<ChevronRight className="w-4 h-4 ml-2" />
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : onRestart}
|
|
||||||
disabled={disabled}
|
|
||||||
className="flex items-center px-3 py-2"
|
|
||||||
>
|
|
||||||
<RotateCcw className="w-4 h-4 mr-2" />
|
|
||||||
{t("restart")}
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
<SpeedControl
|
|
||||||
playbackRate={playbackRate}
|
|
||||||
onPlaybackRateChange={onPlaybackRateChange}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LightButton
|
|
||||||
onClick={disabled ? undefined : onAutoPauseToggle}
|
|
||||||
disabled={disabled}
|
|
||||||
className="flex items-center px-3 py-2"
|
|
||||||
>
|
|
||||||
<Pause className="w-4 h-4 mr-2" />
|
|
||||||
{t("autoPause", { enabled: autoPause ? t("on") : t("off") })}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { SubtitleDisplayProps } from "../../types/subtitle";
|
|
||||||
import SubtitleText from "../atoms/SubtitleText";
|
|
||||||
|
|
||||||
export default function SubtitleArea({ subtitle, onWordClick, settings, className }: SubtitleDisplayProps) {
|
|
||||||
const handleWordClick = React.useCallback((word: string) => {
|
|
||||||
// 打开有道词典页面查询单词
|
|
||||||
window.open(
|
|
||||||
`https://www.youdao.com/result?word=${encodeURIComponent(word)}&lang=en`,
|
|
||||||
"_blank"
|
|
||||||
);
|
|
||||||
onWordClick?.(word);
|
|
||||||
}, [onWordClick]);
|
|
||||||
|
|
||||||
const subtitleStyle = React.useMemo(() => {
|
|
||||||
if (!settings) return { backgroundColor: 'rgba(0, 0, 0, 0.5)' };
|
|
||||||
|
|
||||||
return {
|
|
||||||
backgroundColor: settings.backgroundColor,
|
|
||||||
color: settings.textColor,
|
|
||||||
fontSize: `${settings.fontSize}px`,
|
|
||||||
fontFamily: settings.fontFamily,
|
|
||||||
opacity: settings.opacity,
|
|
||||||
};
|
|
||||||
}, [settings]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SubtitleText
|
|
||||||
text={subtitle}
|
|
||||||
onWordClick={handleWordClick}
|
|
||||||
style={subtitleStyle}
|
|
||||||
className={className}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { Video, FileText } from "lucide-react";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { FileUploadProps } from "../../types/controls";
|
|
||||||
import { useFileUpload } from "../../hooks/useFileUpload";
|
|
||||||
|
|
||||||
export default function UploadZone({ onVideoUpload, onSubtitleUpload, className }: FileUploadProps) {
|
|
||||||
const t = useTranslations("srt_player");
|
|
||||||
const { uploadVideo, uploadSubtitle } = useFileUpload();
|
|
||||||
|
|
||||||
const handleVideoUpload = React.useCallback(() => {
|
|
||||||
uploadVideo(onVideoUpload, (error) => {
|
|
||||||
toast.error(t("videoUploadFailed") + ": " + error.message);
|
|
||||||
});
|
|
||||||
}, [uploadVideo, onVideoUpload, t]);
|
|
||||||
|
|
||||||
const handleSubtitleUpload = React.useCallback(() => {
|
|
||||||
uploadSubtitle(onSubtitleUpload, (error) => {
|
|
||||||
toast.error(t("subtitleUploadFailed") + ": " + error.message);
|
|
||||||
});
|
|
||||||
}, [uploadSubtitle, onSubtitleUpload, t]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex gap-3 ${className || ''}`}>
|
|
||||||
<LightButton
|
|
||||||
onClick={handleVideoUpload}
|
|
||||||
className="flex-1 py-2 px-3 text-sm"
|
|
||||||
>
|
|
||||||
<Video className="w-4 h-4 mr-2" />
|
|
||||||
{t("uploadVideo")}
|
|
||||||
</LightButton>
|
|
||||||
|
|
||||||
<LightButton
|
|
||||||
onClick={handleSubtitleUpload}
|
|
||||||
className="flex-1 py-2 px-3 text-sm"
|
|
||||||
>
|
|
||||||
<FileText className="w-4 h-4 mr-2" />
|
|
||||||
{t("uploadSubtitle")}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React, { forwardRef } from "react";
|
|
||||||
import { VideoElementProps } from "../../types/player";
|
|
||||||
import VideoElement from "../atoms/VideoElement";
|
|
||||||
|
|
||||||
interface VideoPlayerComponentProps extends VideoElementProps {
|
|
||||||
children?: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VideoPlayer = forwardRef<HTMLVideoElement, VideoPlayerComponentProps>(
|
|
||||||
({
|
|
||||||
src,
|
|
||||||
onTimeUpdate,
|
|
||||||
onLoadedMetadata,
|
|
||||||
onPlay,
|
|
||||||
onPause,
|
|
||||||
onEnded,
|
|
||||||
className,
|
|
||||||
children
|
|
||||||
}, ref) => {
|
|
||||||
return (
|
|
||||||
<div className={`w-full flex flex-col ${className || ''}`}>
|
|
||||||
<VideoElement
|
|
||||||
ref={ref}
|
|
||||||
src={src}
|
|
||||||
onTimeUpdate={onTimeUpdate}
|
|
||||||
onLoadedMetadata={onLoadedMetadata}
|
|
||||||
onPlay={onPlay}
|
|
||||||
onPause={onPause}
|
|
||||||
onEnded={onEnded}
|
|
||||||
/>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
VideoPlayer.displayName = "VideoPlayer";
|
|
||||||
|
|
||||||
export default VideoPlayer;
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback } from "react";
|
|
||||||
|
|
||||||
export function useFileUpload() {
|
|
||||||
const uploadFile = useCallback((
|
|
||||||
file: File,
|
|
||||||
onSuccess: (url: string) => void,
|
|
||||||
onError?: (error: Error) => void
|
|
||||||
) => {
|
|
||||||
try {
|
|
||||||
// 验证文件大小(限制为100MB)
|
|
||||||
const maxSize = 100 * 1024 * 1024; // 100MB
|
|
||||||
if (file.size > maxSize) {
|
|
||||||
throw new Error(`文件大小超过限制 (${(file.size / 1024 / 1024).toFixed(2)}MB > 100MB)`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = URL.createObjectURL(file);
|
|
||||||
onSuccess(url);
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage = error instanceof Error ? error.message : '文件上传失败';
|
|
||||||
onError?.(new Error(errorMessage));
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const uploadVideo = useCallback((
|
|
||||||
onVideoUpload: (url: string) => void,
|
|
||||||
onError?: (error: Error) => void
|
|
||||||
) => {
|
|
||||||
const input = document.createElement('input');
|
|
||||||
input.type = 'file';
|
|
||||||
input.accept = 'video/*';
|
|
||||||
|
|
||||||
input.onchange = (e) => {
|
|
||||||
const file = (e.target as HTMLInputElement).files?.[0];
|
|
||||||
if (file) {
|
|
||||||
// 验证文件类型
|
|
||||||
if (!file.type.startsWith('video/')) {
|
|
||||||
onError?.(new Error('请选择有效的视频文件'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uploadFile(file, onVideoUpload, onError);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
input.onerror = () => {
|
|
||||||
onError?.(new Error('文件选择失败'));
|
|
||||||
};
|
|
||||||
|
|
||||||
input.click();
|
|
||||||
}, [uploadFile]);
|
|
||||||
|
|
||||||
const uploadSubtitle = useCallback((
|
|
||||||
onSubtitleUpload: (url: string) => void,
|
|
||||||
onError?: (error: Error) => void
|
|
||||||
) => {
|
|
||||||
const input = document.createElement('input');
|
|
||||||
input.type = 'file';
|
|
||||||
input.accept = '.srt';
|
|
||||||
|
|
||||||
input.onchange = (e) => {
|
|
||||||
const file = (e.target as HTMLInputElement).files?.[0];
|
|
||||||
if (file) {
|
|
||||||
// 验证文件扩展名
|
|
||||||
if (!file.name.toLowerCase().endsWith('.srt')) {
|
|
||||||
onError?.(new Error('请选择.srt格式的字幕文件'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uploadFile(file, onSubtitleUpload, onError);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
input.onerror = () => {
|
|
||||||
onError?.(new Error('文件选择失败'));
|
|
||||||
};
|
|
||||||
|
|
||||||
input.click();
|
|
||||||
}, [uploadFile]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
uploadVideo,
|
|
||||||
uploadSubtitle,
|
|
||||||
uploadFile,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback, useEffect } from "react";
|
|
||||||
import { KeyboardShortcut } from "../types/controls";
|
|
||||||
|
|
||||||
export function useKeyboardShortcuts(
|
|
||||||
shortcuts: KeyboardShortcut[],
|
|
||||||
enabled: boolean = true
|
|
||||||
) {
|
|
||||||
const handleKeyDown = useCallback((event: globalThis.KeyboardEvent) => {
|
|
||||||
if (!enabled) return;
|
|
||||||
|
|
||||||
// 防止在输入框中触发快捷键
|
|
||||||
const target = event.target as HTMLElement;
|
|
||||||
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const shortcut = shortcuts.find(s => s.key === event.key);
|
|
||||||
if (shortcut) {
|
|
||||||
event.preventDefault();
|
|
||||||
shortcut.action();
|
|
||||||
}
|
|
||||||
}, [shortcuts, enabled]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
document.addEventListener('keydown', handleKeyDown);
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener('keydown', handleKeyDown);
|
|
||||||
};
|
|
||||||
}, [handleKeyDown]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createSrtPlayerShortcuts(
|
|
||||||
playPause: () => void,
|
|
||||||
next: () => void,
|
|
||||||
previous: () => void,
|
|
||||||
restart: () => void,
|
|
||||||
toggleAutoPause: () => void
|
|
||||||
): KeyboardShortcut[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
key: ' ',
|
|
||||||
description: '播放/暂停',
|
|
||||||
action: playPause,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'n',
|
|
||||||
description: '下一句',
|
|
||||||
action: next,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'p',
|
|
||||||
description: '上一句',
|
|
||||||
action: previous,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'r',
|
|
||||||
description: '句首',
|
|
||||||
action: restart,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'a',
|
|
||||||
description: '切换自动暂停',
|
|
||||||
action: toggleAutoPause,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,306 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useReducer, useCallback, useRef, useEffect } from "react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { VideoState, VideoControls } from "../types/player";
|
|
||||||
import { SubtitleState, SubtitleEntry } from "../types/subtitle";
|
|
||||||
import { ControlState, ControlActions } from "../types/controls";
|
|
||||||
|
|
||||||
export interface SrtPlayerState {
|
|
||||||
video: VideoState;
|
|
||||||
subtitle: SubtitleState;
|
|
||||||
controls: ControlState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SrtPlayerActions extends VideoControls, ControlActions {
|
|
||||||
setVideoUrl: (url: string | null) => void;
|
|
||||||
setSubtitleUrl: (url: string | null) => void;
|
|
||||||
nextSubtitle: () => void;
|
|
||||||
previousSubtitle: () => void;
|
|
||||||
restartSubtitle: () => void;
|
|
||||||
setSubtitleSettings: (settings: Partial<SubtitleState['settings']>) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const initialState: SrtPlayerState = {
|
|
||||||
video: {
|
|
||||||
url: null,
|
|
||||||
isPlaying: false,
|
|
||||||
currentTime: 0,
|
|
||||||
duration: 0,
|
|
||||||
playbackRate: 1.0,
|
|
||||||
volume: 1.0,
|
|
||||||
},
|
|
||||||
subtitle: {
|
|
||||||
url: null,
|
|
||||||
data: [],
|
|
||||||
currentText: "",
|
|
||||||
currentIndex: null,
|
|
||||||
settings: {
|
|
||||||
fontSize: 24,
|
|
||||||
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
||||||
textColor: "#ffffff",
|
|
||||||
position: "bottom",
|
|
||||||
fontFamily: "sans-serif",
|
|
||||||
opacity: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
controls: {
|
|
||||||
autoPause: true,
|
|
||||||
showShortcuts: false,
|
|
||||||
showSettings: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
type SrtPlayerAction =
|
|
||||||
| { type: "SET_VIDEO_URL"; payload: string | null }
|
|
||||||
| { type: "SET_PLAYING"; payload: boolean }
|
|
||||||
| { type: "SET_CURRENT_TIME"; payload: number }
|
|
||||||
| { type: "SET_DURATION"; payload: number }
|
|
||||||
| { type: "SET_PLAYBACK_RATE"; payload: number }
|
|
||||||
| { type: "SET_VOLUME"; payload: number }
|
|
||||||
| { type: "SET_SUBTITLE_URL"; payload: string | null }
|
|
||||||
| { type: "SET_SUBTITLE_DATA"; payload: SubtitleEntry[] }
|
|
||||||
| { type: "SET_CURRENT_SUBTITLE"; payload: { text: string; index: number | null } }
|
|
||||||
| { type: "SET_SUBTITLE_SETTINGS"; payload: Partial<SubtitleState['settings']> }
|
|
||||||
| { type: "TOGGLE_AUTO_PAUSE" }
|
|
||||||
| { type: "TOGGLE_SHORTCUTS" }
|
|
||||||
| { type: "TOGGLE_SETTINGS" };
|
|
||||||
|
|
||||||
function srtPlayerReducer(state: SrtPlayerState, action: SrtPlayerAction): SrtPlayerState {
|
|
||||||
switch (action.type) {
|
|
||||||
case "SET_VIDEO_URL":
|
|
||||||
return { ...state, video: { ...state.video, url: action.payload } };
|
|
||||||
case "SET_PLAYING":
|
|
||||||
return { ...state, video: { ...state.video, isPlaying: action.payload } };
|
|
||||||
case "SET_CURRENT_TIME":
|
|
||||||
return { ...state, video: { ...state.video, currentTime: action.payload } };
|
|
||||||
case "SET_DURATION":
|
|
||||||
return { ...state, video: { ...state.video, duration: action.payload } };
|
|
||||||
case "SET_PLAYBACK_RATE":
|
|
||||||
return { ...state, video: { ...state.video, playbackRate: action.payload } };
|
|
||||||
case "SET_VOLUME":
|
|
||||||
return { ...state, video: { ...state.video, volume: action.payload } };
|
|
||||||
case "SET_SUBTITLE_URL":
|
|
||||||
return { ...state, subtitle: { ...state.subtitle, url: action.payload } };
|
|
||||||
case "SET_SUBTITLE_DATA":
|
|
||||||
return { ...state, subtitle: { ...state.subtitle, data: action.payload } };
|
|
||||||
case "SET_CURRENT_SUBTITLE":
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
subtitle: {
|
|
||||||
...state.subtitle,
|
|
||||||
currentText: action.payload.text,
|
|
||||||
currentIndex: action.payload.index,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
case "SET_SUBTITLE_SETTINGS":
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
subtitle: {
|
|
||||||
...state.subtitle,
|
|
||||||
settings: { ...state.subtitle.settings, ...action.payload },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
case "TOGGLE_AUTO_PAUSE":
|
|
||||||
return { ...state, controls: { ...state.controls, autoPause: !state.controls.autoPause } };
|
|
||||||
case "TOGGLE_SHORTCUTS":
|
|
||||||
return { ...state, controls: { ...state.controls, showShortcuts: !state.controls.showShortcuts } };
|
|
||||||
case "TOGGLE_SETTINGS":
|
|
||||||
return { ...state, controls: { ...state.controls, showSettings: !state.controls.showSettings } };
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useSrtPlayer() {
|
|
||||||
const [state, dispatch] = useReducer(srtPlayerReducer, initialState);
|
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
|
||||||
|
|
||||||
// Video controls
|
|
||||||
const play = useCallback(() => {
|
|
||||||
// 检查是否同时有视频和字幕
|
|
||||||
if (!state.video.url || !state.subtitle.url || state.subtitle.data.length === 0) {
|
|
||||||
toast.error("请先上传视频和字幕文件");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (videoRef.current) {
|
|
||||||
videoRef.current.play().catch(error => {
|
|
||||||
toast.error("视频播放失败: " + error.message);
|
|
||||||
});
|
|
||||||
dispatch({ type: "SET_PLAYING", payload: true });
|
|
||||||
}
|
|
||||||
}, [state.video.url, state.subtitle.url, state.subtitle.data.length, dispatch]);
|
|
||||||
|
|
||||||
const pause = useCallback(() => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
videoRef.current.pause();
|
|
||||||
dispatch({ type: "SET_PLAYING", payload: false });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const togglePlayPause = useCallback(() => {
|
|
||||||
if (state.video.isPlaying) {
|
|
||||||
pause();
|
|
||||||
} else {
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}, [state.video.isPlaying, play, pause]);
|
|
||||||
|
|
||||||
const seek = useCallback((time: number) => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
videoRef.current.currentTime = time;
|
|
||||||
dispatch({ type: "SET_CURRENT_TIME", payload: time });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const setPlaybackRate = useCallback((rate: number) => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
videoRef.current.playbackRate = rate;
|
|
||||||
dispatch({ type: "SET_PLAYBACK_RATE", payload: rate });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const setVolume = useCallback((volume: number) => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
videoRef.current.volume = volume;
|
|
||||||
dispatch({ type: "SET_VOLUME", payload: volume });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const restart = useCallback(() => {
|
|
||||||
if (videoRef.current && state.subtitle.currentIndex !== null) {
|
|
||||||
const currentSubtitle = state.subtitle.data[state.subtitle.currentIndex];
|
|
||||||
if (currentSubtitle) {
|
|
||||||
seek(currentSubtitle.start);
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [state.subtitle.currentIndex, state.subtitle.data, seek, play]);
|
|
||||||
|
|
||||||
// URL setters
|
|
||||||
const setVideoUrl = useCallback((url: string | null) => {
|
|
||||||
dispatch({ type: "SET_VIDEO_URL", payload: url });
|
|
||||||
if (url && videoRef.current) {
|
|
||||||
videoRef.current.src = url;
|
|
||||||
videoRef.current.load();
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const setSubtitleUrl = useCallback((url: string | null) => {
|
|
||||||
dispatch({ type: "SET_SUBTITLE_URL", payload: url });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Subtitle controls
|
|
||||||
const nextSubtitle = useCallback(() => {
|
|
||||||
if (state.subtitle.currentIndex !== null &&
|
|
||||||
state.subtitle.currentIndex + 1 < state.subtitle.data.length) {
|
|
||||||
const nextIndex = state.subtitle.currentIndex + 1;
|
|
||||||
const nextSubtitle = state.subtitle.data[nextIndex];
|
|
||||||
seek(nextSubtitle.start);
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}, [state.subtitle.currentIndex, state.subtitle.data, seek, play]);
|
|
||||||
|
|
||||||
const previousSubtitle = useCallback(() => {
|
|
||||||
if (state.subtitle.currentIndex !== null && state.subtitle.currentIndex > 0) {
|
|
||||||
const prevIndex = state.subtitle.currentIndex - 1;
|
|
||||||
const prevSubtitle = state.subtitle.data[prevIndex];
|
|
||||||
seek(prevSubtitle.start);
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}, [state.subtitle.currentIndex, state.subtitle.data, seek, play]);
|
|
||||||
|
|
||||||
const restartSubtitle = useCallback(() => {
|
|
||||||
if (state.subtitle.currentIndex !== null) {
|
|
||||||
const currentSubtitle = state.subtitle.data[state.subtitle.currentIndex];
|
|
||||||
seek(currentSubtitle.start);
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
}, [state.subtitle.currentIndex, state.subtitle.data, seek, play]);
|
|
||||||
|
|
||||||
const setSubtitleSettings = useCallback((settings: Partial<SubtitleState['settings']>) => {
|
|
||||||
dispatch({ type: "SET_SUBTITLE_SETTINGS", payload: settings });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Control actions
|
|
||||||
const toggleAutoPause = useCallback(() => {
|
|
||||||
dispatch({ type: "TOGGLE_AUTO_PAUSE" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const toggleShortcuts = useCallback(() => {
|
|
||||||
dispatch({ type: "TOGGLE_SHORTCUTS" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const toggleSettings = useCallback(() => {
|
|
||||||
dispatch({ type: "TOGGLE_SETTINGS" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Video event handlers
|
|
||||||
const handleTimeUpdate = useCallback(() => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
dispatch({ type: "SET_CURRENT_TIME", payload: videoRef.current.currentTime });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleLoadedMetadata = useCallback(() => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
dispatch({ type: "SET_DURATION", payload: videoRef.current.duration });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handlePlay = useCallback(() => {
|
|
||||||
dispatch({ type: "SET_PLAYING", payload: true });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handlePause = useCallback(() => {
|
|
||||||
dispatch({ type: "SET_PLAYING", payload: false });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Set subtitle data
|
|
||||||
const setSubtitleData = useCallback((data: SubtitleEntry[]) => {
|
|
||||||
dispatch({ type: "SET_SUBTITLE_DATA", payload: data });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Set current subtitle
|
|
||||||
const setCurrentSubtitle = useCallback((text: string, index: number | null) => {
|
|
||||||
dispatch({ type: "SET_CURRENT_SUBTITLE", payload: { text, index } });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const actions: SrtPlayerActions = {
|
|
||||||
play,
|
|
||||||
pause,
|
|
||||||
togglePlayPause,
|
|
||||||
seek,
|
|
||||||
setPlaybackRate,
|
|
||||||
setVolume,
|
|
||||||
restart,
|
|
||||||
setVideoUrl,
|
|
||||||
setSubtitleUrl,
|
|
||||||
nextSubtitle,
|
|
||||||
previousSubtitle,
|
|
||||||
restartSubtitle,
|
|
||||||
setSubtitleSettings,
|
|
||||||
toggleAutoPause,
|
|
||||||
toggleShortcuts,
|
|
||||||
toggleSettings,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
state,
|
|
||||||
actions,
|
|
||||||
videoRef,
|
|
||||||
videoEventHandlers: {
|
|
||||||
onTimeUpdate: handleTimeUpdate,
|
|
||||||
onLoadedMetadata: handleLoadedMetadata,
|
|
||||||
onPlay: handlePlay,
|
|
||||||
onPause: handlePause,
|
|
||||||
},
|
|
||||||
subtitleActions: {
|
|
||||||
setSubtitleData,
|
|
||||||
setCurrentSubtitle,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UseSrtPlayerReturn = ReturnType<typeof useSrtPlayer>;
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef } from "react";
|
|
||||||
import { SubtitleEntry } from "../types/subtitle";
|
|
||||||
|
|
||||||
export function useSubtitleSync(
|
|
||||||
subtitles: SubtitleEntry[],
|
|
||||||
currentTime: number,
|
|
||||||
isPlaying: boolean,
|
|
||||||
autoPause: boolean,
|
|
||||||
onSubtitleChange: (subtitle: SubtitleEntry | null) => void,
|
|
||||||
onAutoPauseTrigger?: (subtitle: SubtitleEntry) => void
|
|
||||||
) {
|
|
||||||
const lastSubtitleRef = useRef<SubtitleEntry | null>(null);
|
|
||||||
const rafIdRef = useRef<number>(0);
|
|
||||||
|
|
||||||
// 获取当前时间对应的字幕
|
|
||||||
const getCurrentSubtitle = useCallback((time: number): SubtitleEntry | null => {
|
|
||||||
return subtitles.find(subtitle => time >= subtitle.start && time <= subtitle.end) || null;
|
|
||||||
}, [subtitles]);
|
|
||||||
|
|
||||||
// 获取最近的字幕索引
|
|
||||||
const getNearestIndex = useCallback((time: number): number | null => {
|
|
||||||
if (subtitles.length === 0) return null;
|
|
||||||
|
|
||||||
// 如果时间早于第一个字幕开始时间
|
|
||||||
if (time < subtitles[0].start) return null;
|
|
||||||
|
|
||||||
// 如果时间晚于最后一个字幕结束时间
|
|
||||||
if (time > subtitles[subtitles.length - 1].end) return subtitles.length - 1;
|
|
||||||
|
|
||||||
// 二分查找找到当前时间对应的字幕
|
|
||||||
let left = 0;
|
|
||||||
let right = subtitles.length - 1;
|
|
||||||
|
|
||||||
while (left <= right) {
|
|
||||||
const mid = Math.floor((left + right) / 2);
|
|
||||||
const subtitle = subtitles[mid];
|
|
||||||
|
|
||||||
if (time >= subtitle.start && time <= subtitle.end) {
|
|
||||||
return mid;
|
|
||||||
} else if (time < subtitle.start) {
|
|
||||||
right = mid - 1;
|
|
||||||
} else {
|
|
||||||
left = mid + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果没有找到完全匹配的字幕,返回最近的字幕索引
|
|
||||||
return right >= 0 ? right : null;
|
|
||||||
}, [subtitles]);
|
|
||||||
|
|
||||||
// 检查是否需要自动暂停
|
|
||||||
const shouldAutoPause = useCallback((subtitle: SubtitleEntry, time: number): boolean => {
|
|
||||||
return autoPause &&
|
|
||||||
time >= subtitle.end - 0.2 && // 增加时间窗口,确保自动暂停更可靠
|
|
||||||
time < subtitle.end;
|
|
||||||
}, [autoPause]);
|
|
||||||
|
|
||||||
// 启动/停止同步循环
|
|
||||||
useEffect(() => {
|
|
||||||
const syncSubtitles = () => {
|
|
||||||
const currentSubtitle = getCurrentSubtitle(currentTime);
|
|
||||||
|
|
||||||
// 检查字幕是否发生变化
|
|
||||||
if (currentSubtitle !== lastSubtitleRef.current) {
|
|
||||||
const previousSubtitle = lastSubtitleRef.current;
|
|
||||||
lastSubtitleRef.current = currentSubtitle;
|
|
||||||
|
|
||||||
// 只有当有当前字幕时才调用onSubtitleChange
|
|
||||||
// 在字幕间隙时保持之前的字幕索引,避免进度条跳到0
|
|
||||||
if (currentSubtitle) {
|
|
||||||
onSubtitleChange(currentSubtitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否需要自动暂停
|
|
||||||
// 每次都检查,不只在字幕变化时检查
|
|
||||||
if (currentSubtitle && shouldAutoPause(currentSubtitle, currentTime)) {
|
|
||||||
onAutoPauseTrigger?.(currentSubtitle);
|
|
||||||
} else if (!currentSubtitle && lastSubtitleRef.current && shouldAutoPause(lastSubtitleRef.current, currentTime)) {
|
|
||||||
// 在字幕结束时,如果前一个字幕需要自动暂停,也要触发
|
|
||||||
onAutoPauseTrigger?.(lastSubtitleRef.current);
|
|
||||||
}
|
|
||||||
|
|
||||||
rafIdRef.current = requestAnimationFrame(syncSubtitles);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (subtitles.length > 0) {
|
|
||||||
rafIdRef.current = requestAnimationFrame(syncSubtitles);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (rafIdRef.current) {
|
|
||||||
cancelAnimationFrame(rafIdRef.current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [subtitles.length, currentTime, getCurrentSubtitle, onSubtitleChange, shouldAutoPause, onAutoPauseTrigger]);
|
|
||||||
|
|
||||||
// 重置最后字幕引用
|
|
||||||
useEffect(() => {
|
|
||||||
lastSubtitleRef.current = null;
|
|
||||||
}, [subtitles]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
getCurrentSubtitle,
|
|
||||||
getNearestIndex,
|
|
||||||
shouldAutoPause,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { Video, FileText } from "lucide-react";
|
|
||||||
import { useSrtPlayer } from "./hooks/useSrtPlayer";
|
|
||||||
import { useSubtitleSync } from "./hooks/useSubtitleSync";
|
|
||||||
import { useKeyboardShortcuts, createSrtPlayerShortcuts } from "./hooks/useKeyboardShortcuts";
|
|
||||||
import { useFileUpload } from "./hooks/useFileUpload";
|
|
||||||
import { loadSubtitle } from "./utils/subtitleParser";
|
|
||||||
import VideoPlayer from "./components/compounds/VideoPlayer";
|
|
||||||
import SubtitleArea from "./components/compounds/SubtitleArea";
|
|
||||||
import ControlBar from "./components/compounds/ControlBar";
|
|
||||||
import UploadZone from "./components/compounds/UploadZone";
|
|
||||||
import SeekBar from "./components/atoms/SeekBar";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
|
|
||||||
export default function SrtPlayerPage() {
|
|
||||||
const t = useTranslations("home");
|
|
||||||
const srtT = useTranslations("srt_player");
|
|
||||||
const { uploadVideo, uploadSubtitle } = useFileUpload();
|
|
||||||
const {
|
|
||||||
state,
|
|
||||||
actions,
|
|
||||||
videoRef,
|
|
||||||
videoEventHandlers,
|
|
||||||
subtitleActions
|
|
||||||
} = useSrtPlayer();
|
|
||||||
|
|
||||||
// 字幕同步
|
|
||||||
useSubtitleSync(
|
|
||||||
state.subtitle.data,
|
|
||||||
state.video.currentTime,
|
|
||||||
state.video.isPlaying,
|
|
||||||
state.controls.autoPause,
|
|
||||||
(subtitle) => {
|
|
||||||
if (subtitle) {
|
|
||||||
subtitleActions.setCurrentSubtitle(subtitle.text, subtitle.index);
|
|
||||||
} else {
|
|
||||||
subtitleActions.setCurrentSubtitle("", null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(subtitle) => {
|
|
||||||
// 自动暂停逻辑
|
|
||||||
actions.seek(subtitle.start);
|
|
||||||
actions.pause();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 键盘快捷键
|
|
||||||
const shortcuts = React.useMemo(() =>
|
|
||||||
createSrtPlayerShortcuts(
|
|
||||||
actions.togglePlayPause,
|
|
||||||
actions.nextSubtitle,
|
|
||||||
actions.previousSubtitle,
|
|
||||||
actions.restartSubtitle,
|
|
||||||
actions.toggleAutoPause
|
|
||||||
), [
|
|
||||||
actions.togglePlayPause,
|
|
||||||
actions.nextSubtitle,
|
|
||||||
actions.previousSubtitle,
|
|
||||||
actions.restartSubtitle,
|
|
||||||
actions.toggleAutoPause
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
useKeyboardShortcuts(shortcuts);
|
|
||||||
|
|
||||||
// 处理字幕文件加载
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (state.subtitle.url) {
|
|
||||||
loadSubtitle(state.subtitle.url)
|
|
||||||
.then(subtitleData => {
|
|
||||||
subtitleActions.setSubtitleData(subtitleData);
|
|
||||||
toast.success(srtT("subtitleLoadSuccess"));
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
toast.error(srtT("subtitleLoadFailed") + ": " + error.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [srtT, state.subtitle.url, subtitleActions]);
|
|
||||||
|
|
||||||
// 处理进度条变化
|
|
||||||
const handleSeek = React.useCallback((index: number) => {
|
|
||||||
if (state.subtitle.data[index]) {
|
|
||||||
actions.seek(state.subtitle.data[index].start);
|
|
||||||
}
|
|
||||||
}, [state.subtitle.data, actions]);
|
|
||||||
|
|
||||||
// 处理视频上传
|
|
||||||
const handleVideoUpload = React.useCallback(() => {
|
|
||||||
uploadVideo(actions.setVideoUrl, (error) => {
|
|
||||||
toast.error(srtT("videoUploadFailed") + ": " + error.message);
|
|
||||||
});
|
|
||||||
}, [uploadVideo, actions.setVideoUrl, srtT]);
|
|
||||||
|
|
||||||
// 处理字幕上传
|
|
||||||
const handleSubtitleUpload = React.useCallback(() => {
|
|
||||||
uploadSubtitle(actions.setSubtitleUrl, (error) => {
|
|
||||||
toast.error(srtT("subtitleUploadFailed") + ": " + error.message);
|
|
||||||
});
|
|
||||||
}, [uploadSubtitle, actions.setSubtitleUrl, srtT]);
|
|
||||||
|
|
||||||
// 检查是否可以播放
|
|
||||||
const canPlay = state.video.url && state.subtitle.url && state.subtitle.data.length > 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-gray-50">
|
|
||||||
<div className="container mx-auto px-4 py-8">
|
|
||||||
<div className="max-w-6xl mx-auto">
|
|
||||||
{/* 标题区域 */}
|
|
||||||
<div className="text-center mb-8">
|
|
||||||
<h1 className="text-4xl font-bold text-gray-800 mb-2">
|
|
||||||
{t("srtPlayer.name")}
|
|
||||||
</h1>
|
|
||||||
<p className="text-lg text-gray-600">
|
|
||||||
{t("srtPlayer.description")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 主要内容区域 */}
|
|
||||||
<div className="bg-white rounded-xl shadow-lg overflow-hidden">
|
|
||||||
{/* 视频播放器区域 */}
|
|
||||||
<div className="aspect-video bg-black relative">
|
|
||||||
{(!state.video.url || !state.subtitle.url || state.subtitle.data.length === 0) && (
|
|
||||||
<div className="absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-75 z-10">
|
|
||||||
<div className="text-center text-white">
|
|
||||||
<p className="text-lg mb-2">
|
|
||||||
{!state.video.url && !state.subtitle.url
|
|
||||||
? srtT("uploadVideoAndSubtitle")
|
|
||||||
: !state.video.url
|
|
||||||
? srtT("uploadVideoFile")
|
|
||||||
: !state.subtitle.url
|
|
||||||
? srtT("uploadSubtitleFile")
|
|
||||||
: srtT("processingSubtitle")
|
|
||||||
}
|
|
||||||
</p>
|
|
||||||
{(!state.video.url || !state.subtitle.url) && (
|
|
||||||
<p className="text-sm text-gray-300">
|
|
||||||
{srtT("needBothFiles")}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{state.video.url && (
|
|
||||||
<VideoPlayer
|
|
||||||
ref={videoRef}
|
|
||||||
src={state.video.url}
|
|
||||||
{...videoEventHandlers}
|
|
||||||
className="w-full h-full"
|
|
||||||
>
|
|
||||||
{state.subtitle.url && state.subtitle.data.length > 0 && (
|
|
||||||
<SubtitleArea
|
|
||||||
subtitle={state.subtitle.currentText}
|
|
||||||
settings={state.subtitle.settings}
|
|
||||||
className="absolute bottom-0 left-0 right-0 px-4 py-2"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</VideoPlayer>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 控制面板 */}
|
|
||||||
<div className="p-3 bg-gray-50 border-t">
|
|
||||||
{/* 上传区域和状态指示器 */}
|
|
||||||
<div className="mb-3">
|
|
||||||
<div className="flex gap-3">
|
|
||||||
<div className={`flex-1 p-2 rounded-lg border-2 transition-all ${state.video.url
|
|
||||||
? 'border-gray-800 bg-gray-100'
|
|
||||||
: 'border-gray-300 bg-white'
|
|
||||||
}`}>
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Video className="w-5 h-5 text-gray-600" />
|
|
||||||
<div className="text-left">
|
|
||||||
<h3 className="font-semibold text-gray-800 text-sm">{srtT("videoFile")}</h3>
|
|
||||||
<p className="text-xs text-gray-600">
|
|
||||||
{state.video.url ? srtT("uploaded") : srtT("notUploaded")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<LightButton
|
|
||||||
onClick={state.video.url ? undefined : handleVideoUpload}
|
|
||||||
disabled={!!state.video.url}
|
|
||||||
className="px-2 py-1 text-xs"
|
|
||||||
>
|
|
||||||
{state.video.url ? srtT("uploaded") : srtT("upload")}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={`flex-1 p-2 rounded-lg border-2 transition-all ${state.subtitle.url
|
|
||||||
? 'border-gray-800 bg-gray-100'
|
|
||||||
: 'border-gray-300 bg-white'
|
|
||||||
}`}>
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<FileText className="w-5 h-5 text-gray-600" />
|
|
||||||
<div className="text-left">
|
|
||||||
<h3 className="font-semibold text-gray-800 text-sm">{srtT("subtitleFile")}</h3>
|
|
||||||
<p className="text-xs text-gray-600">
|
|
||||||
{state.subtitle.url ? srtT("uploaded") : srtT("notUploaded")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<LightButton
|
|
||||||
onClick={state.subtitle.url ? undefined : handleSubtitleUpload}
|
|
||||||
disabled={!!state.subtitle.url}
|
|
||||||
className="px-2 py-1 text-xs"
|
|
||||||
>
|
|
||||||
{state.subtitle.url ? srtT("uploaded") : srtT("upload")}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 控制按钮和进度条 */}
|
|
||||||
<div className={`space-y-4 ${canPlay ? '' : 'opacity-50 pointer-events-none'}`}>
|
|
||||||
{/* 控制按钮 */}
|
|
||||||
<ControlBar
|
|
||||||
isPlaying={state.video.isPlaying}
|
|
||||||
onPlayPause={actions.togglePlayPause}
|
|
||||||
onPrevious={actions.previousSubtitle}
|
|
||||||
onNext={actions.nextSubtitle}
|
|
||||||
onRestart={actions.restartSubtitle}
|
|
||||||
playbackRate={state.video.playbackRate}
|
|
||||||
onPlaybackRateChange={actions.setPlaybackRate}
|
|
||||||
autoPause={state.controls.autoPause}
|
|
||||||
onAutoPauseToggle={actions.toggleAutoPause}
|
|
||||||
disabled={!canPlay}
|
|
||||||
className="justify-center"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 进度条 */}
|
|
||||||
<div className="space-y-2">
|
|
||||||
<SeekBar
|
|
||||||
value={state.subtitle.currentIndex ?? 0}
|
|
||||||
max={Math.max(0, state.subtitle.data.length - 1)}
|
|
||||||
onChange={handleSeek}
|
|
||||||
disabled={!canPlay}
|
|
||||||
className="h-3"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 字幕进度显示 */}
|
|
||||||
<div className="flex justify-between items-center text-sm text-gray-600 px-2">
|
|
||||||
<span>
|
|
||||||
{state.subtitle.currentIndex !== null ?
|
|
||||||
`${state.subtitle.currentIndex + 1}/${state.subtitle.data.length}` :
|
|
||||||
'0/0'
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-4">
|
|
||||||
{/* 播放速度显示 */}
|
|
||||||
<span className="bg-gray-200 px-2 py-1 rounded text-xs">
|
|
||||||
{state.video.playbackRate}x
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{/* 自动暂停状态 */}
|
|
||||||
<span className={`px-2 py-1 rounded text-xs ${state.controls.autoPause
|
|
||||||
? 'bg-gray-800 text-white'
|
|
||||||
: 'bg-gray-100 text-gray-600'
|
|
||||||
}`}>
|
|
||||||
{srtT("autoPauseStatus", { enabled: state.controls.autoPause ? srtT("on") : srtT("off") })}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
export interface ControlState {
|
|
||||||
autoPause: boolean;
|
|
||||||
showShortcuts: boolean;
|
|
||||||
showSettings: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ControlActions {
|
|
||||||
toggleAutoPause: () => void;
|
|
||||||
toggleShortcuts: () => void;
|
|
||||||
toggleSettings: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ControlBarProps {
|
|
||||||
isPlaying: boolean;
|
|
||||||
onPlayPause: () => void;
|
|
||||||
onPrevious: () => void;
|
|
||||||
onNext: () => void;
|
|
||||||
onRestart: () => void;
|
|
||||||
playbackRate: number;
|
|
||||||
onPlaybackRateChange: (rate: number) => void;
|
|
||||||
autoPause: boolean;
|
|
||||||
onAutoPauseToggle: () => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavigationButtonProps {
|
|
||||||
onClick: () => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AutoPauseToggleProps {
|
|
||||||
enabled: boolean;
|
|
||||||
onToggle: () => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface KeyboardShortcut {
|
|
||||||
key: string;
|
|
||||||
description: string;
|
|
||||||
action: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ShortcutHintProps {
|
|
||||||
shortcuts: KeyboardShortcut[];
|
|
||||||
visible: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileUploadProps {
|
|
||||||
onVideoUpload: (url: string) => void;
|
|
||||||
onSubtitleUpload: (url: string) => void;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileInputProps {
|
|
||||||
accept: string;
|
|
||||||
onFileSelect: (file: File) => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
export interface VideoState {
|
|
||||||
url: string | null;
|
|
||||||
isPlaying: boolean;
|
|
||||||
currentTime: number;
|
|
||||||
duration: number;
|
|
||||||
playbackRate: number;
|
|
||||||
volume: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VideoControls {
|
|
||||||
play: () => void;
|
|
||||||
pause: () => void;
|
|
||||||
togglePlayPause: () => void;
|
|
||||||
seek: (time: number) => void;
|
|
||||||
setPlaybackRate: (rate: number) => void;
|
|
||||||
setVolume: (volume: number) => void;
|
|
||||||
restart: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VideoElementProps {
|
|
||||||
src?: string;
|
|
||||||
onTimeUpdate?: (time: number) => void;
|
|
||||||
onLoadedMetadata?: (duration: number) => void;
|
|
||||||
onPlay?: () => void;
|
|
||||||
onPause?: () => void;
|
|
||||||
onEnded?: () => void;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PlayButtonProps {
|
|
||||||
isPlaying: boolean;
|
|
||||||
onToggle: () => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SeekBarProps {
|
|
||||||
value: number;
|
|
||||||
max: number;
|
|
||||||
onChange: (value: number) => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SpeedControlProps {
|
|
||||||
playbackRate: number;
|
|
||||||
onPlaybackRateChange: (rate: number) => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VolumeControlProps {
|
|
||||||
volume: number;
|
|
||||||
onVolumeChange: (volume: number) => void;
|
|
||||||
disabled?: boolean;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
export interface SubtitleEntry {
|
|
||||||
start: number;
|
|
||||||
end: number;
|
|
||||||
text: string;
|
|
||||||
index: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleState {
|
|
||||||
url: string | null;
|
|
||||||
data: SubtitleEntry[];
|
|
||||||
currentText: string;
|
|
||||||
currentIndex: number | null;
|
|
||||||
settings: SubtitleSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleSettings {
|
|
||||||
fontSize: number;
|
|
||||||
backgroundColor: string;
|
|
||||||
textColor: string;
|
|
||||||
position: 'top' | 'center' | 'bottom';
|
|
||||||
fontFamily: string;
|
|
||||||
opacity: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleDisplayProps {
|
|
||||||
subtitle: string;
|
|
||||||
onWordClick?: (word: string) => void;
|
|
||||||
settings?: SubtitleSettings;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleTextProps {
|
|
||||||
text: string;
|
|
||||||
onWordClick?: (word: string) => void;
|
|
||||||
style?: React.CSSProperties;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleSettingsProps {
|
|
||||||
settings: SubtitleSettings;
|
|
||||||
onSettingsChange: (settings: SubtitleSettings) => void;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleControls {
|
|
||||||
next: () => void;
|
|
||||||
previous: () => void;
|
|
||||||
goToIndex: (index: number) => void;
|
|
||||||
toggleAutoPause: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubtitleSyncProps {
|
|
||||||
subtitles: SubtitleEntry[];
|
|
||||||
currentTime: number;
|
|
||||||
isPlaying: boolean;
|
|
||||||
autoPause: boolean;
|
|
||||||
onSubtitleChange: (subtitle: SubtitleEntry | null) => void;
|
|
||||||
onAutoPauseTrigger?: (subtitle: SubtitleEntry) => void;
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
import { SubtitleEntry } from "../types/subtitle";
|
|
||||||
import { logger } from "@/lib/logger";
|
|
||||||
|
|
||||||
export function parseSrt(data: string): SubtitleEntry[] {
|
|
||||||
const lines = data.split(/\r?\n/);
|
|
||||||
const result: SubtitleEntry[] = [];
|
|
||||||
const re = new RegExp(
|
|
||||||
"(\\d{2}:\\d{2}:\\d{2},\\d{3})\\s*-->\\s*(\\d{2}:\\d{2}:\\d{2},\\d{3})",
|
|
||||||
);
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
while (i < lines.length) {
|
|
||||||
if (!lines[i].trim()) {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
if (i >= lines.length) break;
|
|
||||||
|
|
||||||
const timeMatch = lines[i].match(re);
|
|
||||||
if (!timeMatch) {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const start = toSeconds(timeMatch[1]);
|
|
||||||
const end = toSeconds(timeMatch[2]);
|
|
||||||
i++;
|
|
||||||
|
|
||||||
let text = "";
|
|
||||||
while (i < lines.length && lines[i].trim()) {
|
|
||||||
text += lines[i] + "\n";
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.push({
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
text: text.trim(),
|
|
||||||
index: result.length,
|
|
||||||
});
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getSubtitleIndex(
|
|
||||||
subtitles: SubtitleEntry[],
|
|
||||||
currentTime: number,
|
|
||||||
): number | null {
|
|
||||||
for (let i = 0; i < subtitles.length; i++) {
|
|
||||||
if (currentTime >= subtitles[i].start && currentTime <= subtitles[i].end) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getNearestIndex(
|
|
||||||
subtitles: SubtitleEntry[],
|
|
||||||
currentTime: number,
|
|
||||||
): number | null {
|
|
||||||
for (let i = 0; i < subtitles.length; i++) {
|
|
||||||
const subtitle = subtitles[i];
|
|
||||||
const isBefore = currentTime - subtitle.start >= 0;
|
|
||||||
const isAfter = currentTime - subtitle.end >= 0;
|
|
||||||
|
|
||||||
if (!isBefore || !isAfter) return i - 1;
|
|
||||||
if (isBefore && !isAfter) return i;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCurrentSubtitle(
|
|
||||||
subtitles: SubtitleEntry[],
|
|
||||||
currentTime: number,
|
|
||||||
): SubtitleEntry | null {
|
|
||||||
return subtitles.find((subtitle) =>
|
|
||||||
currentTime >= subtitle.start && currentTime <= subtitle.end
|
|
||||||
) || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toSeconds(timeStr: string): number {
|
|
||||||
const [h, m, s] = timeStr.replace(",", ".").split(":");
|
|
||||||
return parseFloat(
|
|
||||||
(parseInt(h) * 3600 + parseInt(m) * 60 + parseFloat(s)).toFixed(3),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function loadSubtitle(url: string): Promise<SubtitleEntry[]> {
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
const data = await response.text();
|
|
||||||
return parseSrt(data);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('加载字幕失败', error);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
export function formatTime(seconds: number): string {
|
|
||||||
const hours = Math.floor(seconds / 3600);
|
|
||||||
const minutes = Math.floor((seconds % 3600) / 60);
|
|
||||||
const secs = Math.floor(seconds % 60);
|
|
||||||
|
|
||||||
if (hours > 0) {
|
|
||||||
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function timeToSeconds(timeStr: string): number {
|
|
||||||
const parts = timeStr.split(':');
|
|
||||||
|
|
||||||
if (parts.length === 3) {
|
|
||||||
// HH:MM:SS format
|
|
||||||
const [h, m, s] = parts;
|
|
||||||
return parseInt(h) * 3600 + parseInt(m) * 60 + parseFloat(s);
|
|
||||||
} else if (parts.length === 2) {
|
|
||||||
// MM:SS format
|
|
||||||
const [m, s] = parts;
|
|
||||||
return parseInt(m) * 60 + parseFloat(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function secondsToTime(seconds: number): string {
|
|
||||||
const hours = Math.floor(seconds / 3600);
|
|
||||||
const minutes = Math.floor((seconds % 3600) / 60);
|
|
||||||
const secs = Math.floor(seconds % 60);
|
|
||||||
const ms = Math.floor((seconds % 1) * 1000);
|
|
||||||
|
|
||||||
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')},${ms.toString().padStart(3, '0')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function clampTime(time: number, min: number = 0, max: number = Infinity): number {
|
|
||||||
return Math.min(Math.max(time, min), max);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getPlaybackRateOptions(): number[] {
|
|
||||||
return [0.5, 0.7, 1.0, 1.2, 1.5, 2.0];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getPlaybackRateLabel(rate: number): string {
|
|
||||||
return `${rate}x`;
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import Container from "@/components/ui/Container";
|
|
||||||
import { TranslationHistorySchema } from "@/lib/interfaces";
|
|
||||||
import { Dispatch, useEffect, useState } from "react";
|
|
||||||
import z from "zod";
|
|
||||||
import { Folder } from "../../../../generated/prisma/browser";
|
|
||||||
import { getFoldersByUserId } from "@/lib/server/services/folderService";
|
|
||||||
import { Folder as Fd } from "lucide-react";
|
|
||||||
import { createPair } from "@/lib/server/services/pairService";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
|
|
||||||
interface AddToFolderProps {
|
|
||||||
item: z.infer<typeof TranslationHistorySchema>;
|
|
||||||
setShow: Dispatch<React.SetStateAction<boolean>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AddToFolder: React.FC<AddToFolderProps> = ({ item, setShow }) => {
|
|
||||||
const { data: session } = authClient.useSession();
|
|
||||||
const [folders, setFolders] = useState<Folder[]>([]);
|
|
||||||
const t = useTranslations("translator.add_to_folder");
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!session) return;
|
|
||||||
const userId = session.user.id;
|
|
||||||
getFoldersByUserId(userId)
|
|
||||||
.then(setFolders)
|
|
||||||
.then(() => setLoading(false));
|
|
||||||
}, [session]);
|
|
||||||
|
|
||||||
|
|
||||||
if (!session) {
|
|
||||||
return (
|
|
||||||
<div className="fixed left-0 top-0 z-50 w-screen h-screen bg-black/50 flex justify-center items-center">
|
|
||||||
<Container className="p-6">
|
|
||||||
<div>{t("notAuthenticated")}</div>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="fixed left-0 top-0 z-50 w-screen h-screen bg-black/50 flex justify-center items-center">
|
|
||||||
<Container className="p-6">
|
|
||||||
<h1>{t("chooseFolder")}</h1>
|
|
||||||
<div className="border border-gray-200 rounded-2xl">
|
|
||||||
{(loading && <span>...</span>) ||
|
|
||||||
(folders.length > 0 &&
|
|
||||||
folders.map((folder) => (
|
|
||||||
<button
|
|
||||||
key={folder.id}
|
|
||||||
className="p-2 flex items-center justify-start hover:bg-gray-50 gap-2 hover:cursor-pointer w-full border-b border-gray-200"
|
|
||||||
onClick={() => {
|
|
||||||
createPair({
|
|
||||||
text1: item.text1,
|
|
||||||
text2: item.text2,
|
|
||||||
language1: item.language1,
|
|
||||||
language2: item.language2,
|
|
||||||
folderId: folder.id,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
toast.success(t("success"));
|
|
||||||
setShow(false);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
toast.error(t("error"));
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Fd />
|
|
||||||
{t("folderInfo", { id: folder.id, name: folder.name })}
|
|
||||||
</button>
|
|
||||||
))) || <div>{t("noFolders")}</div>}
|
|
||||||
</div>
|
|
||||||
<LightButton onClick={() => setShow(false)}>{t("close")}</LightButton>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddToFolder;
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
import Container from "@/components/ui/Container";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { Folder } from "../../../../generated/prisma/browser";
|
|
||||||
import { getFoldersByUserId } from "@/lib/server/services/folderService";
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { Folder as Fd } from "lucide-react";
|
|
||||||
|
|
||||||
interface FolderSelectorProps {
|
|
||||||
setSelectedFolderId: (id: number) => void;
|
|
||||||
userId: string;
|
|
||||||
cancel: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const FolderSelector: React.FC<FolderSelectorProps> = ({
|
|
||||||
setSelectedFolderId,
|
|
||||||
userId,
|
|
||||||
cancel,
|
|
||||||
}) => {
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [folders, setFolders] = useState<Folder[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
getFoldersByUserId(userId)
|
|
||||||
.then(setFolders)
|
|
||||||
.then(() => setLoading(false));
|
|
||||||
}, [userId]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`bg-black/50 fixed inset-0 z-50 flex justify-center items-center`}
|
|
||||||
>
|
|
||||||
<Container className="p-6">
|
|
||||||
{(loading && <p>Loading...</p>) ||
|
|
||||||
(folders.length > 0 && (
|
|
||||||
<>
|
|
||||||
<h1>Select a Folder</h1>
|
|
||||||
<div className="m-2 border-gray-200 border rounded-2xl max-h-96 overflow-y-auto">
|
|
||||||
{folders.map((folder) => (
|
|
||||||
<button
|
|
||||||
className="p-2 w-full flex hover:bg-gray-50 gap-2"
|
|
||||||
key={folder.id}
|
|
||||||
onClick={() => setSelectedFolderId(folder.id)}
|
|
||||||
>
|
|
||||||
<Fd />
|
|
||||||
{folder.id}. {folder.name}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)) || <p>No folders found</p>}
|
|
||||||
<LightButton onClick={cancel}>Cancel</LightButton>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FolderSelector;
|
|
||||||
@@ -1,344 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { LightButton } from "@/components/ui/buttons";
|
|
||||||
import { IconClick } from "@/components/ui/buttons";
|
|
||||||
import IMAGES from "@/config/images";
|
|
||||||
import { useAudioPlayer } from "@/hooks/useAudioPlayer";
|
|
||||||
import { TranslationHistorySchema } from "@/lib/interfaces";
|
|
||||||
import { tlsoPush, tlso } from "@/lib/browser/localStorageOperators";
|
|
||||||
import { logger } from "@/lib/logger";
|
|
||||||
import { Plus, Trash } from "lucide-react";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
import { useRef, useState } from "react";
|
|
||||||
import z from "zod";
|
|
||||||
import AddToFolder from "./AddToFolder";
|
|
||||||
import { translateText } from "@/lib/server/bigmodel/translatorActions";
|
|
||||||
import type { TranslateTextOutput } from "@/lib/server/services/types";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import FolderSelector from "./FolderSelector";
|
|
||||||
import { createPair } from "@/lib/server/services/pairService";
|
|
||||||
import { shallowEqual } from "@/lib/utils";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import { getTTSUrl, TTS_SUPPORTED_LANGUAGES } from "@/lib/server/bigmodel/tts";
|
|
||||||
|
|
||||||
export default function TranslatorPage() {
|
|
||||||
const t = useTranslations("translator");
|
|
||||||
|
|
||||||
const taref = useRef<HTMLTextAreaElement>(null);
|
|
||||||
const [targetLanguage, setTargetLanguage] = useState<string>("Chinese");
|
|
||||||
const [translationResult, setTranslationResult] = useState<TranslateTextOutput | null>(null);
|
|
||||||
const [needIpa, setNeedIpa] = useState(true);
|
|
||||||
const [processing, setProcessing] = useState(false);
|
|
||||||
const [lastTranslation, setLastTranslation] = useState<{
|
|
||||||
sourceText: string;
|
|
||||||
targetLanguage: string;
|
|
||||||
} | null>(null);
|
|
||||||
const { load, play } = useAudioPlayer();
|
|
||||||
const [history, setHistory] = useState<z.infer<typeof TranslationHistorySchema>[]>(() => tlso.get());
|
|
||||||
const [showAddToFolder, setShowAddToFolder] = useState(false);
|
|
||||||
const [addToFolderItem, setAddToFolderItem] = useState<z.infer<
|
|
||||||
typeof TranslationHistorySchema
|
|
||||||
> | null>(null);
|
|
||||||
const lastTTS = useRef({
|
|
||||||
text: "",
|
|
||||||
url: "",
|
|
||||||
});
|
|
||||||
const [autoSave, setAutoSave] = useState(false);
|
|
||||||
const [autoSaveFolderId, setAutoSaveFolderId] = useState<number | null>(null);
|
|
||||||
const { data: session } = authClient.useSession();
|
|
||||||
|
|
||||||
const tts = async (text: string, locale: string) => {
|
|
||||||
if (lastTTS.current.text !== text) {
|
|
||||||
try {
|
|
||||||
// Map language name to TTS format
|
|
||||||
let theLanguage = locale.toLowerCase().replace(/[^a-z]/g, '').replace(/^./, match => match.toUpperCase());
|
|
||||||
|
|
||||||
// Check if language is in TTS supported list
|
|
||||||
const supportedLanguages: TTS_SUPPORTED_LANGUAGES[] = [
|
|
||||||
"Auto", "Chinese", "English", "German", "Italian", "Portuguese",
|
|
||||||
"Spanish", "Japanese", "Korean", "French", "Russian"
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!supportedLanguages.includes(theLanguage as TTS_SUPPORTED_LANGUAGES)) {
|
|
||||||
theLanguage = "Auto";
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = await getTTSUrl(text, theLanguage as TTS_SUPPORTED_LANGUAGES);
|
|
||||||
await load(url);
|
|
||||||
lastTTS.current.text = text;
|
|
||||||
lastTTS.current.url = url;
|
|
||||||
} catch (error) {
|
|
||||||
toast.error("Failed to generate audio");
|
|
||||||
logger.error("生成音频失败", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await play();
|
|
||||||
};
|
|
||||||
|
|
||||||
const translate = async () => {
|
|
||||||
if (!taref.current || processing) return;
|
|
||||||
|
|
||||||
setProcessing(true);
|
|
||||||
|
|
||||||
const sourceText = taref.current.value;
|
|
||||||
|
|
||||||
// 判断是否需要强制重新翻译
|
|
||||||
// 只有当源文本和目标语言都与上次相同时,才强制重新翻译
|
|
||||||
const forceRetranslate =
|
|
||||||
lastTranslation?.sourceText === sourceText &&
|
|
||||||
lastTranslation?.targetLanguage === targetLanguage;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await translateText({
|
|
||||||
sourceText,
|
|
||||||
targetLanguage,
|
|
||||||
forceRetranslate,
|
|
||||||
needIpa,
|
|
||||||
userId: session?.user?.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
setTranslationResult(result);
|
|
||||||
setLastTranslation({
|
|
||||||
sourceText,
|
|
||||||
targetLanguage,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 更新本地历史记录
|
|
||||||
const historyItem = {
|
|
||||||
text1: result.sourceText,
|
|
||||||
text2: result.translatedText,
|
|
||||||
language1: result.sourceLanguage,
|
|
||||||
language2: result.targetLanguage,
|
|
||||||
};
|
|
||||||
setHistory(tlsoPush(historyItem));
|
|
||||||
|
|
||||||
// 自动保存到文件夹
|
|
||||||
if (autoSave && autoSaveFolderId) {
|
|
||||||
createPair({
|
|
||||||
text1: result.sourceText,
|
|
||||||
text2: result.translatedText,
|
|
||||||
language1: result.sourceLanguage,
|
|
||||||
language2: result.targetLanguage,
|
|
||||||
ipa1: result.sourceIpa || undefined,
|
|
||||||
ipa2: result.targetIpa || undefined,
|
|
||||||
folderId: autoSaveFolderId,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
toast.success(`${sourceText} 保存到文件夹 ${autoSaveFolderId} 成功`);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
toast.error(`保存失败: ${error.message}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
toast.error("翻译失败,请重试");
|
|
||||||
console.error("翻译错误:", error);
|
|
||||||
} finally {
|
|
||||||
setProcessing(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{/* TCard Component */}
|
|
||||||
<div className="w-screen flex flex-col md:flex-row md:justify-between gap-2 p-2">
|
|
||||||
{/* Card Component - Left Side */}
|
|
||||||
<div className="w-full md:w-1/2 flex flex-col-reverse gap-2">
|
|
||||||
{/* ICard1 Component */}
|
|
||||||
<div className="border border-gray-200 rounded-2xl w-full h-64 p-2">
|
|
||||||
<textarea
|
|
||||||
className="resize-none h-8/12 w-full focus:outline-0"
|
|
||||||
ref={taref}
|
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.ctrlKey && e.key === "Enter") translate();
|
|
||||||
}}
|
|
||||||
></textarea>
|
|
||||||
<div className="ipa w-full h-2/12 overflow-auto text-gray-600">
|
|
||||||
{translationResult?.sourceIpa || ""}
|
|
||||||
</div>
|
|
||||||
<div className="h-2/12 w-full flex justify-end items-center">
|
|
||||||
<IconClick
|
|
||||||
src={IMAGES.copy_all}
|
|
||||||
alt="copy"
|
|
||||||
onClick={async () => {
|
|
||||||
await navigator.clipboard.writeText(
|
|
||||||
taref.current?.value || "",
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
></IconClick>
|
|
||||||
<IconClick
|
|
||||||
src={IMAGES.play_arrow}
|
|
||||||
alt="play"
|
|
||||||
onClick={() => {
|
|
||||||
const t = taref.current?.value;
|
|
||||||
if (!t) return;
|
|
||||||
tts(t, translationResult?.sourceLanguage || "");
|
|
||||||
}}
|
|
||||||
></IconClick>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="option1 w-full flex flex-row justify-between items-center">
|
|
||||||
<span>{t("detectLanguage")}</span>
|
|
||||||
<LightButton
|
|
||||||
selected={needIpa}
|
|
||||||
onClick={() => setNeedIpa((prev) => !prev)}
|
|
||||||
>
|
|
||||||
{t("generateIPA")}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Card Component - Right Side */}
|
|
||||||
<div className="w-full md:w-1/2 flex flex-col-reverse gap-2">
|
|
||||||
{/* ICard2 Component */}
|
|
||||||
<div className="bg-gray-100 rounded-2xl w-full h-64 p-2">
|
|
||||||
<div className="h-2/3 w-full overflow-y-auto">{translationResult?.translatedText || ""}</div>
|
|
||||||
<div className="ipa w-full h-1/6 overflow-y-auto text-gray-600">
|
|
||||||
{translationResult?.targetIpa || ""}
|
|
||||||
</div>
|
|
||||||
<div className="h-1/6 w-full flex justify-end items-center">
|
|
||||||
<IconClick
|
|
||||||
src={IMAGES.copy_all}
|
|
||||||
alt="copy"
|
|
||||||
onClick={async () => {
|
|
||||||
await navigator.clipboard.writeText(translationResult?.translatedText || "");
|
|
||||||
}}
|
|
||||||
></IconClick>
|
|
||||||
<IconClick
|
|
||||||
src={IMAGES.play_arrow}
|
|
||||||
alt="play"
|
|
||||||
onClick={() => {
|
|
||||||
if (!translationResult) return;
|
|
||||||
tts(
|
|
||||||
translationResult.translatedText,
|
|
||||||
translationResult.targetLanguage,
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
></IconClick>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="option2 w-full flex gap-1 items-center flex-wrap">
|
|
||||||
<span>{t("translateInto")}</span>
|
|
||||||
<LightButton
|
|
||||||
selected={targetLanguage === "Chinese"}
|
|
||||||
onClick={() => setTargetLanguage("Chinese")}
|
|
||||||
>
|
|
||||||
{t("chinese")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={targetLanguage === "English"}
|
|
||||||
onClick={() => setTargetLanguage("English")}
|
|
||||||
>
|
|
||||||
{t("english")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={targetLanguage === "Italian"}
|
|
||||||
onClick={() => setTargetLanguage("Italian")}
|
|
||||||
>
|
|
||||||
{t("italian")}
|
|
||||||
</LightButton>
|
|
||||||
<LightButton
|
|
||||||
selected={!["Chinese", "English", "Italian"].includes(targetLanguage)}
|
|
||||||
onClick={() => {
|
|
||||||
const newLang = prompt(t("enterLanguage"));
|
|
||||||
if (newLang) {
|
|
||||||
setTargetLanguage(newLang);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("other")}
|
|
||||||
</LightButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* TranslateButton Component */}
|
|
||||||
<div className="w-screen flex justify-center items-center">
|
|
||||||
<button
|
|
||||||
className={`duration-150 ease-in text-xl font-extrabold border rounded-4xl p-3 border-gray-200 h-16 ${processing ? "bg-gray-200" : "bg-white hover:bg-gray-200 hover:cursor-pointer"}`}
|
|
||||||
onClick={translate}
|
|
||||||
>
|
|
||||||
{t("translate")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* AutoSave Component */}
|
|
||||||
<div className="w-screen flex justify-center items-center">
|
|
||||||
<label className="flex items-center">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={autoSave}
|
|
||||||
onChange={(e) => {
|
|
||||||
const checked = e.target.checked;
|
|
||||||
if (checked === true && !session) {
|
|
||||||
toast.warning("Please login to enable auto-save");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checked === false) setAutoSaveFolderId(null);
|
|
||||||
setAutoSave(checked);
|
|
||||||
}}
|
|
||||||
className="mr-2"
|
|
||||||
/>
|
|
||||||
{t("autoSave")}
|
|
||||||
{autoSaveFolderId ? ` (${autoSaveFolderId})` : ""}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{history.length > 0 && (
|
|
||||||
<div className="m-6 flex flex-col items-center">
|
|
||||||
<h1 className="text-2xl font-light">{t("history")}</h1>
|
|
||||||
<div className="border border-gray-200 rounded-2xl m-4">
|
|
||||||
{history.toReversed().map((item, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="border-b border-gray-200 p-2 group hover:bg-gray-50 flex gap-2 flex-row justify-between items-start"
|
|
||||||
>
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
<p className="text-sm font-light">{item.text1}</p>
|
|
||||||
<p className="text-sm font-light">{item.text2}</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
if (!session?.user) {
|
|
||||||
toast.info("请先登录后再保存到文件夹");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setShowAddToFolder(true);
|
|
||||||
setAddToFolderItem(item);
|
|
||||||
}}
|
|
||||||
className="hover:bg-gray-200 hover:cursor-pointer rounded-4xl border border-gray-200 w-8 h-8 flex justify-center items-center"
|
|
||||||
>
|
|
||||||
<Plus />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
setHistory(
|
|
||||||
tlso.set(
|
|
||||||
tlso.get().filter((v) => !shallowEqual(v, item)),
|
|
||||||
) || [],
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
className="hover:bg-gray-200 hover:cursor-pointer rounded-4xl border border-gray-200 w-8 h-8 flex justify-center items-center"
|
|
||||||
>
|
|
||||||
<Trash />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{showAddToFolder && (
|
|
||||||
<AddToFolder setShow={setShowAddToFolder} item={addToFolderItem!} />
|
|
||||||
)}
|
|
||||||
{autoSave && !autoSaveFolderId && (
|
|
||||||
<FolderSelector
|
|
||||||
userId={session!.user.id as string}
|
|
||||||
cancel={() => setAutoSave(false)}
|
|
||||||
setSelectedFolderId={(id) => setAutoSaveFolderId(id)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
import { LightButton } from "@/components/ui/buttons";
|
import LightButton from "@/components/buttons/LightButton";
|
||||||
import { IconClick } from "@/components/ui/buttons";
|
import IconClick from "@/components/IconClick";
|
||||||
import IMAGES from "@/config/images";
|
import IMAGES from "@/config/images";
|
||||||
import { Letter, SupportedAlphabets } from "@/lib/interfaces";
|
import { Letter, SupportedAlphabets } from "@/interfaces";
|
||||||
import {
|
import {
|
||||||
Dispatch,
|
Dispatch,
|
||||||
KeyboardEvent,
|
KeyboardEvent,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
useCallback,
|
|
||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
@@ -20,26 +19,25 @@ export default function MemoryCard({
|
|||||||
setChosenAlphabet: Dispatch<SetStateAction<SupportedAlphabets | null>>;
|
setChosenAlphabet: Dispatch<SetStateAction<SupportedAlphabets | null>>;
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations("alphabet");
|
const t = useTranslations("alphabet");
|
||||||
const [index, setIndex] = useState(() => alphabet.length > 0 ? Math.floor(Math.random() * alphabet.length) : 0);
|
const [index, setIndex] = useState(
|
||||||
|
Math.floor(Math.random() * alphabet.length),
|
||||||
|
);
|
||||||
const [more, setMore] = useState(false);
|
const [more, setMore] = useState(false);
|
||||||
const [ipaDisplay, setIPADisplay] = useState(true);
|
const [ipaDisplay, setIPADisplay] = useState(true);
|
||||||
const [letterDisplay, setLetterDisplay] = useState(true);
|
const [letterDisplay, setLetterDisplay] = useState(true);
|
||||||
|
|
||||||
const refresh = useCallback(() => {
|
|
||||||
if (alphabet.length > 0) {
|
|
||||||
setIndex(Math.floor(Math.random() * alphabet.length));
|
|
||||||
}
|
|
||||||
}, [alphabet.length]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeydown = (e: globalThis.KeyboardEvent) => {
|
const handleKeydown = (e: globalThis.KeyboardEvent) => {
|
||||||
if (e.key === " ") refresh();
|
if (e.key === " ") refresh();
|
||||||
};
|
};
|
||||||
document.addEventListener("keydown", handleKeydown);
|
document.addEventListener("keydown", handleKeydown);
|
||||||
return () => document.removeEventListener("keydown", handleKeydown);
|
return () => document.removeEventListener("keydown", handleKeydown);
|
||||||
}, [refresh]);
|
});
|
||||||
|
|
||||||
const letter = alphabet[index] || { letter: "", letter_name_ipa: "", letter_sound_ipa: "" };
|
const letter = alphabet[index];
|
||||||
|
const refresh = () => {
|
||||||
|
setIndex(Math.floor(Math.random() * alphabet.length));
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full flex justify-center items-center"
|
className="w-full flex justify-center items-center"
|
||||||
97
src/app/alphabet/page.tsx
Normal file
97
src/app/alphabet/page.tsx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import LightButton from "@/components/buttons/LightButton";
|
||||||
|
import { Letter, SupportedAlphabets } from "@/interfaces";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import MemoryCard from "./MemoryCard";
|
||||||
|
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
|
export default function Alphabet() {
|
||||||
|
const t = useTranslations("alphabet");
|
||||||
|
const [chosenAlphabet, setChosenAlphabet] =
|
||||||
|
useState<SupportedAlphabets | null>(null);
|
||||||
|
const [alphabetData, setAlphabetData] = useState<
|
||||||
|
Record<SupportedAlphabets, Letter[] | null>
|
||||||
|
>({
|
||||||
|
japanese: null,
|
||||||
|
english: null,
|
||||||
|
esperanto: null,
|
||||||
|
uyghur: null,
|
||||||
|
});
|
||||||
|
const [loadingState, setLoadingState] = useState<
|
||||||
|
"idle" | "loading" | "success" | "error"
|
||||||
|
>("idle");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (chosenAlphabet && !alphabetData[chosenAlphabet]) {
|
||||||
|
setLoadingState("loading");
|
||||||
|
|
||||||
|
fetch("/alphabets/" + chosenAlphabet + ".json")
|
||||||
|
.then((res) => {
|
||||||
|
if (!res.ok) throw new Error("Network response was not ok");
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then((obj) => {
|
||||||
|
setAlphabetData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[chosenAlphabet]: obj as Letter[],
|
||||||
|
}));
|
||||||
|
setLoadingState("success");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setLoadingState("error");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [chosenAlphabet, alphabetData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (loadingState === "error") {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setLoadingState("idle");
|
||||||
|
setChosenAlphabet(null);
|
||||||
|
}, 2000);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}
|
||||||
|
}, [loadingState]);
|
||||||
|
|
||||||
|
if (!chosenAlphabet)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="border border-gray-200 m-4 mt-4 flex flex-col justify-center items-center p-4 rounded-2xl gap-2">
|
||||||
|
<span className="text-2xl md:text-3xl">{t("chooseCharacters")}</span>
|
||||||
|
<div className="flex gap-1 flex-wrap">
|
||||||
|
<LightButton onClick={() => setChosenAlphabet("japanese")}>
|
||||||
|
{t("japanese")}
|
||||||
|
</LightButton>
|
||||||
|
<LightButton onClick={() => setChosenAlphabet("english")}>
|
||||||
|
{t("english")}
|
||||||
|
</LightButton>
|
||||||
|
<LightButton onClick={() => setChosenAlphabet("uyghur")}>
|
||||||
|
{t("uyghur")}
|
||||||
|
</LightButton>
|
||||||
|
<LightButton onClick={() => setChosenAlphabet("esperanto")}>
|
||||||
|
{t("esperanto")}
|
||||||
|
</LightButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
if (loadingState === "loading") {
|
||||||
|
return t("loading");
|
||||||
|
}
|
||||||
|
if (loadingState === "error") {
|
||||||
|
return t("loadFailed");
|
||||||
|
}
|
||||||
|
if (loadingState === "success" && alphabetData[chosenAlphabet]) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MemoryCard
|
||||||
|
alphabet={alphabetData[chosenAlphabet]}
|
||||||
|
setChosenAlphabet={setChosenAlphabet}
|
||||||
|
></MemoryCard>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import { auth } from "@/auth";
|
|
||||||
import { toNextJsHandler } from "better-auth/next-js";
|
|
||||||
|
|
||||||
export const { POST, GET } = toNextJsHandler(auth);
|
|
||||||
15
src/app/api/auth/[...nextauth]/route.ts
Normal file
15
src/app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import NextAuth, { AuthOptions } from "next-auth";
|
||||||
|
import GithubProvider from "next-auth/providers/github";
|
||||||
|
|
||||||
|
export const authOptions: AuthOptions = {
|
||||||
|
providers: [
|
||||||
|
GithubProvider({
|
||||||
|
clientId: process.env.GITHUB_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const handler = NextAuth(authOptions);
|
||||||
|
|
||||||
|
export { handler as GET, handler as POST };
|
||||||
18
src/app/api/folder/[id]/route.ts
Normal file
18
src/app/api/folder/[id]/route.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { getServerSession } from "next-auth";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { authOptions } from "../../auth/[...nextauth]/route";
|
||||||
|
import { WordPairController } from "@/lib/db";
|
||||||
|
|
||||||
|
export async function GET({ params }: { params: { slug: number } }) {
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
if (session) {
|
||||||
|
const id = params.slug;
|
||||||
|
return new NextResponse(
|
||||||
|
JSON.stringify(
|
||||||
|
await WordPairController.getWordPairsByFolderId(id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new NextResponse("Unauthorized");
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/app/api/folders/route.ts
Normal file
35
src/app/api/folders/route.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { getServerSession } from "next-auth";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { authOptions } from "../auth/[...nextauth]/route";
|
||||||
|
import { FolderController } from "@/lib/db";
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
if (session) {
|
||||||
|
return new NextResponse(
|
||||||
|
JSON.stringify(
|
||||||
|
await FolderController.getFoldersByOwner(session.user!.name as string),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new NextResponse("Unauthorized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(req: NextRequest) {
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
if (session) {
|
||||||
|
const body = await req.json();
|
||||||
|
|
||||||
|
return new NextResponse(
|
||||||
|
JSON.stringify(
|
||||||
|
await FolderController.createFolder(
|
||||||
|
body.name,
|
||||||
|
session.user!.name as string,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new NextResponse("Unauthorized");
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/app/api/ipa/route.ts
Normal file
62
src/app/api/ipa/route.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { callZhipuAPI, handleAPIError } from "@/utils";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
async function getIPA(text: string) {
|
||||||
|
console.log(`get ipa of ${text}`);
|
||||||
|
const messages = [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `
|
||||||
|
请推断以下文本的语言,生成对应的宽式国际音标(IPA)以及locale,以JSON格式返回
|
||||||
|
[${text}]
|
||||||
|
结果如:
|
||||||
|
{
|
||||||
|
"ipa": "[ni˨˩˦ xɑʊ˨˩˦]",
|
||||||
|
"locale": "zh-CN"
|
||||||
|
}
|
||||||
|
注意:
|
||||||
|
直接返回json文本,
|
||||||
|
ipa一定要加[],
|
||||||
|
locale如果可能有多个,选取最可能的一个,其中使用符号"-",
|
||||||
|
locale如果推断失败,就返回{"locale": "en-US"}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
const response = await callZhipuAPI(messages);
|
||||||
|
let to_parse = response.choices[0].message.content.trim() as string;
|
||||||
|
if (to_parse.startsWith("`"))
|
||||||
|
to_parse = to_parse.slice(7, to_parse.length - 3);
|
||||||
|
if (to_parse.length === 0) throw Error("ai啥也每说");
|
||||||
|
return JSON.parse(to_parse);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const text = searchParams.get("text");
|
||||||
|
|
||||||
|
if (!text) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "查询参数错误", message: "text参数是必需的" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const textInfo = await getIPA(text);
|
||||||
|
if (!textInfo) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "服务暂时不可用", message: "LLM API 请求失败" },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(textInfo, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
handleAPIError(error, "请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/app/api/locale/route.ts
Normal file
64
src/app/api/locale/route.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import { callZhipuAPI } from "@/utils";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
async function getLocale(text: string) {
|
||||||
|
console.log(`get locale of ${text}`);
|
||||||
|
const messages = [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `
|
||||||
|
请推断以下文本的的locale,以JSON格式返回
|
||||||
|
[${text}]
|
||||||
|
结果如:
|
||||||
|
{
|
||||||
|
"locale": "zh-CN"
|
||||||
|
}
|
||||||
|
注意:
|
||||||
|
直接返回json文本,
|
||||||
|
locale如果可能有多个,选取最可能的一个,其中使用符号"-",
|
||||||
|
locale如果推断失败,就返回{"locale": "en-US"}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
const response = await callZhipuAPI(messages);
|
||||||
|
let to_parse = response.choices[0].message.content.trim() as string;
|
||||||
|
if (to_parse.startsWith("`"))
|
||||||
|
to_parse = to_parse.slice(7, to_parse.length - 3);
|
||||||
|
if (to_parse.length === 0) throw Error("ai啥也每说");
|
||||||
|
return JSON.parse(to_parse);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const text = searchParams.get("text");
|
||||||
|
|
||||||
|
if (!text) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "查询参数错误", message: "text参数是必需的" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const textInfo = await getLocale(text.slice(0, 30));
|
||||||
|
if (!textInfo) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "服务暂时不可用", message: "LLM API 请求失败" },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(textInfo, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("API 错误:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "服务器内部错误", message: "请稍后重试" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/app/api/route.ts
Normal file
12
src/app/api/route.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
const url = request.url;
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
message: "Hello World",
|
||||||
|
url: url,
|
||||||
|
},
|
||||||
|
{ status: 200 },
|
||||||
|
);
|
||||||
|
}
|
||||||
66
src/app/api/translate/route.ts
Normal file
66
src/app/api/translate/route.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { callZhipuAPI } from "@/utils";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
async function translate(text: string, target_lang: string) {
|
||||||
|
console.log(`translate "${text}" into ${target_lang}`);
|
||||||
|
const messages = [
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `
|
||||||
|
请推断以下文本的locale,并翻译到目标语言${target_lang},同样需要locale信息,以JSON格式返回
|
||||||
|
[${text}]
|
||||||
|
结果如:
|
||||||
|
{
|
||||||
|
"source_locale": "zh-CN",
|
||||||
|
"target_locale": "de-DE",
|
||||||
|
"target_text": "Halo"
|
||||||
|
}
|
||||||
|
注意:
|
||||||
|
直接返回json文本,
|
||||||
|
locale如果可能有多个,选取最可能的一个,其中使用符号"-",
|
||||||
|
locale如果推断失败,就当作是en-US
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
const response = await callZhipuAPI(messages);
|
||||||
|
let to_parse = response.choices[0].message.content.trim() as string;
|
||||||
|
if (to_parse.startsWith("`"))
|
||||||
|
to_parse = to_parse.slice(7, to_parse.length - 3);
|
||||||
|
if (to_parse.length === 0) throw Error("ai啥也每说");
|
||||||
|
return JSON.parse(to_parse);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const text = searchParams.get("text");
|
||||||
|
const target_lang = searchParams.get("target");
|
||||||
|
|
||||||
|
if (!text || !target_lang) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "查询参数错误", message: "text参数, target参数是必需的" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const textInfo = await translate(text, target_lang);
|
||||||
|
if (!textInfo) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "服务暂时不可用", message: "LLM API 请求失败" },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return NextResponse.json(textInfo, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("API 错误:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "服务器内部错误", message: "请稍后重试" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/app/api/v1/ipa/route.ts
Normal file
10
src/app/api/v1/ipa/route.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { simpleGetLLMAnswer } from "@/lib/ai";
|
||||||
|
import { NextRequest } from "next/server";
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
return await simpleGetLLMAnswer(
|
||||||
|
`请生成%s的严式国际音标(International Phonetic Alphabet),然后直接发给我。`,
|
||||||
|
req.nextUrl.searchParams,
|
||||||
|
["text"],
|
||||||
|
);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user