mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-28 02:51:56 +08:00
更新国际化支持
This commit is contained in:
@@ -14,6 +14,7 @@ import SubscribeEditDialog from '../dialog/SubscribeEditDialog.vue'
|
||||
import SearchSiteDialog from '@/components/dialog/SearchSiteDialog.vue'
|
||||
import SubscribeSeasonDialog from '../dialog/SubscribeSeasonDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getMeidaTypeText } from '@/types/i18n-type'
|
||||
|
||||
// 国际化
|
||||
const { t } = useI18n()
|
||||
@@ -486,7 +487,7 @@ function onRemoveSubscribe() {
|
||||
:class="getChipColor(props.media?.type || '')"
|
||||
class="absolute left-2 top-2 bg-opacity-80 text-white font-bold"
|
||||
>
|
||||
{{ props.media?.type }}
|
||||
{{ getMeidaTypeText(props.media?.type) }}
|
||||
</VChip>
|
||||
<!-- 本地存在标识 -->
|
||||
<ExistIcon v-if="isExists && !hover.isHovering" />
|
||||
|
||||
@@ -22,6 +22,13 @@ export default {
|
||||
saving: 'Saving',
|
||||
reset: 'Reset',
|
||||
},
|
||||
mediaType: {
|
||||
movie: 'Movie',
|
||||
tv: 'TV Show',
|
||||
anime: 'Anime',
|
||||
collection: 'Collection',
|
||||
unknown: 'Unknown',
|
||||
},
|
||||
theme: {
|
||||
light: 'Light',
|
||||
dark: 'Dark',
|
||||
|
||||
@@ -22,6 +22,13 @@ export default {
|
||||
saving: '保存中',
|
||||
reset: '重置',
|
||||
},
|
||||
mediaType: {
|
||||
movie: '电影',
|
||||
tv: '电视剧',
|
||||
anime: '动漫',
|
||||
collection: '合集',
|
||||
unknown: '未知',
|
||||
},
|
||||
theme: {
|
||||
light: '浅色',
|
||||
dark: '深色',
|
||||
|
||||
1401
src/locales/zh-TW.ts
Normal file
1401
src/locales/zh-TW.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ import { SUPPORTED_LOCALES, SupportedLocale } from '@/types/i18n'
|
||||
|
||||
// 导入语言文件
|
||||
import zhCN from '@/locales/zh-CN'
|
||||
import zhTW from '@/locales/zh-TW'
|
||||
import enUS from '@/locales/en-US'
|
||||
|
||||
// 创建 i18n 实例
|
||||
@@ -13,6 +14,7 @@ const i18n = createI18n({
|
||||
fallbackLocale: 'zh-CN', // 回退语言
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
'zh-TW': zhTW,
|
||||
'en-US': enUS,
|
||||
},
|
||||
silentTranslationWarn: true,
|
||||
|
||||
1
src/types/colorthief.d.ts
vendored
1
src/types/colorthief.d.ts
vendored
@@ -1 +0,0 @@
|
||||
|
||||
23
src/types/i18n-type.ts
Normal file
23
src/types/i18n-type.ts
Normal 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
|
||||
}
|
||||
@@ -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',
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"baseUrl": "./",
|
||||
"target": "esnext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "Node16",
|
||||
"moduleResolution": "node16",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
@@ -73,4 +73,4 @@
|
||||
"node_modules",
|
||||
"src/@iconify/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user