Skip to content

Latest commit

 

History

History
88 lines (67 loc) · 2.8 KB

File metadata and controls

88 lines (67 loc) · 2.8 KB

多语言视频标题支持 / Multilingual Video Title Support

概述 / Overview

为Veo3 AI视频生成器的画廊功能添加了多语言支持,用户可以根据选择的语言显示中文或英文的视频标题和描述。

Added multilingual support to the Veo3 AI video generator gallery feature, allowing users to view video titles and descriptions in Chinese or English based on their selected language.

数据库更改 / Database Changes

新增字段 / New Fields

  • title_en - 英文标题
  • description_en - 英文描述
  • title_en 字段添加了索引以提高查询性能

数据迁移 / Data Migration

  • 自动将现有中文标题翻译为英文
  • 为所有现有记录添加英文描述

实现细节 / Implementation Details

前端组件 / Frontend Components

  • GalleryGrid: 更新以显示本地化标题
  • GalleryPage: 添加语言切换支持
  • 工具函数: utils/gallery-i18n.ts 处理本地化逻辑

TypeScript 类型 / TypeScript Types

  • 更新 GalleryItem 接口以包含 title_endescription_en 字段

数据库模型 / Database Models

  • 更新查询以包含多语言字段
  • 添加本地化辅助函数

使用方法 / Usage

运行数据迁移 / Running Migration

方法1:使用 Shell 脚本 / Using Shell Script

# 确保设置了环境变量
export SUPABASE_DB_HOST=your_host
export SUPABASE_DB_PASSWORD=your_password

# 运行迁移
./scripts/migrate-multilingual-gallery.sh

方法2:使用 Node.js 脚本 / Using Node.js Script

# 确保 .env 文件包含 SUPABASE_URL 和 SUPABASE_SERVICE_KEY
node scripts/migrate-multilingual-gallery.js

# 或使用直接方法
node scripts/migrate-multilingual-gallery.js --direct

前端使用 / Frontend Usage

import { getLocalizedTitle, getLocalizedDescription } from '@/utils/gallery-i18n';
import { useLocale } from 'next-intl';

const locale = useLocale();
const title = getLocalizedTitle(galleryItem, locale);
const description = getLocalizedDescription(galleryItem, locale);

翻译映射 / Translation Mapping

中文 English
老奶奶说唱 Grandma Rap
动物比中指 Animal Middle Finger
雪床 Snow Bed
苹果耳机广告 Apple Earphone Ad
潜水员开箱 Diver Unboxing
拆箱动画 Unboxing Animation
手环广告 Bracelet Advertisement
电影连续镜头 Movie Continuous Shot
动物世界 Animal World
自然风光 Natural Scenery
人物肖像 Portrait
抽象艺术 Abstract Art
精彩AI视频 Amazing AI Video

注意事项 / Notes

  • 新添加的视频应该同时包含中文和英文标题
  • 前端会根据用户选择的语言自动切换显示
  • 如果某种语言的标题不存在,会降级显示另一种语言的标题