更新国际化支持

This commit is contained in:
jxxghp
2025-04-28 15:12:07 +08:00
parent 308a8ab30d
commit 6be4694327
9 changed files with 1450 additions and 11 deletions

View File

@@ -1 +0,0 @@

23
src/types/i18n-type.ts Normal file
View File

@@ -0,0 +1,23 @@
// 将中文标签转换为当前语言的标签
export function getMeidaTypeText(label: string | undefined) {
if (!label) return ''
const { t } = useI18n()
// 常见的媒体类型及其映射
const typeMap: Record<string, string> = {
'电影': 'mediaType.movie',
'电视剧': 'mediaType.tv',
'动漫': 'mediaType.anime',
'合集': 'mediaType.collection',
'未知': 'mediaType.unknown',
}
// 如果是已知类型使用i18n翻译
if (label in typeMap) {
return t(typeMap[label])
}
// 对于未知的类型,直接返回原始标签
return label
}

View File

@@ -1,9 +1,3 @@
import zhCN from '@/locales/zh-CN'
// 导出类型和常量,而不是作为语言消息文件
export type MessageSchema = typeof zhCN
export type LocaleKey = keyof typeof zhCN
export interface LocaleInfo {
name: string
title: string
@@ -16,6 +10,11 @@ export const SUPPORTED_LOCALES: Record<string, LocaleInfo> = {
title: '简体中文',
flag: '🇨🇳',
},
'zh-TW': {
name: 'zh-TW',
title: '繁體中文',
flag: '🇨🇳',
},
'en-US': {
name: 'en-US',
title: 'English',