mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +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 SearchSiteDialog from '@/components/dialog/SearchSiteDialog.vue'
|
||||||
import SubscribeSeasonDialog from '../dialog/SubscribeSeasonDialog.vue'
|
import SubscribeSeasonDialog from '../dialog/SubscribeSeasonDialog.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { getMeidaTypeText } from '@/types/i18n-type'
|
||||||
|
|
||||||
// 国际化
|
// 国际化
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
@@ -486,7 +487,7 @@ function onRemoveSubscribe() {
|
|||||||
:class="getChipColor(props.media?.type || '')"
|
:class="getChipColor(props.media?.type || '')"
|
||||||
class="absolute left-2 top-2 bg-opacity-80 text-white font-bold"
|
class="absolute left-2 top-2 bg-opacity-80 text-white font-bold"
|
||||||
>
|
>
|
||||||
{{ props.media?.type }}
|
{{ getMeidaTypeText(props.media?.type) }}
|
||||||
</VChip>
|
</VChip>
|
||||||
<!-- 本地存在标识 -->
|
<!-- 本地存在标识 -->
|
||||||
<ExistIcon v-if="isExists && !hover.isHovering" />
|
<ExistIcon v-if="isExists && !hover.isHovering" />
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ export default {
|
|||||||
saving: 'Saving',
|
saving: 'Saving',
|
||||||
reset: 'Reset',
|
reset: 'Reset',
|
||||||
},
|
},
|
||||||
|
mediaType: {
|
||||||
|
movie: 'Movie',
|
||||||
|
tv: 'TV Show',
|
||||||
|
anime: 'Anime',
|
||||||
|
collection: 'Collection',
|
||||||
|
unknown: 'Unknown',
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
light: 'Light',
|
light: 'Light',
|
||||||
dark: 'Dark',
|
dark: 'Dark',
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ export default {
|
|||||||
saving: '保存中',
|
saving: '保存中',
|
||||||
reset: '重置',
|
reset: '重置',
|
||||||
},
|
},
|
||||||
|
mediaType: {
|
||||||
|
movie: '电影',
|
||||||
|
tv: '电视剧',
|
||||||
|
anime: '动漫',
|
||||||
|
collection: '合集',
|
||||||
|
unknown: '未知',
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
light: '浅色',
|
light: '浅色',
|
||||||
dark: '深色',
|
dark: '深色',
|
||||||
|
|||||||
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 zhCN from '@/locales/zh-CN'
|
||||||
|
import zhTW from '@/locales/zh-TW'
|
||||||
import enUS from '@/locales/en-US'
|
import enUS from '@/locales/en-US'
|
||||||
|
|
||||||
// 创建 i18n 实例
|
// 创建 i18n 实例
|
||||||
@@ -13,6 +14,7 @@ const i18n = createI18n({
|
|||||||
fallbackLocale: 'zh-CN', // 回退语言
|
fallbackLocale: 'zh-CN', // 回退语言
|
||||||
messages: {
|
messages: {
|
||||||
'zh-CN': zhCN,
|
'zh-CN': zhCN,
|
||||||
|
'zh-TW': zhTW,
|
||||||
'en-US': enUS,
|
'en-US': enUS,
|
||||||
},
|
},
|
||||||
silentTranslationWarn: true,
|
silentTranslationWarn: true,
|
||||||
|
|||||||
Vendored
-1
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -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
|
||||||
|
}
|
||||||
+5
-6
@@ -1,9 +1,3 @@
|
|||||||
import zhCN from '@/locales/zh-CN'
|
|
||||||
|
|
||||||
// 导出类型和常量,而不是作为语言消息文件
|
|
||||||
export type MessageSchema = typeof zhCN
|
|
||||||
export type LocaleKey = keyof typeof zhCN
|
|
||||||
|
|
||||||
export interface LocaleInfo {
|
export interface LocaleInfo {
|
||||||
name: string
|
name: string
|
||||||
title: string
|
title: string
|
||||||
@@ -16,6 +10,11 @@ export const SUPPORTED_LOCALES: Record<string, LocaleInfo> = {
|
|||||||
title: '简体中文',
|
title: '简体中文',
|
||||||
flag: '🇨🇳',
|
flag: '🇨🇳',
|
||||||
},
|
},
|
||||||
|
'zh-TW': {
|
||||||
|
name: 'zh-TW',
|
||||||
|
title: '繁體中文',
|
||||||
|
flag: '🇨🇳',
|
||||||
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
name: 'en-US',
|
name: 'en-US',
|
||||||
title: 'English',
|
title: 'English',
|
||||||
|
|||||||
+3
-3
@@ -3,8 +3,8 @@
|
|||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"module": "Node16",
|
"module": "ESNext",
|
||||||
"moduleResolution": "node16",
|
"moduleResolution": "bundler",
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
@@ -73,4 +73,4 @@
|
|||||||
"node_modules",
|
"node_modules",
|
||||||
"src/@iconify/*"
|
"src/@iconify/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user