mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 11:02:21 -08:00
refactor(core): CORE-12 type template resources and verify bundled notices
This commit is contained in:
1 parent
b8039ad1f1
commit
9eb7c945ca
101 files changed
+7363
-664
No files matched your search
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const ar = {
|
||||
'Video Info': 'معلومات الفيديو',
|
||||
'Close': 'إغلاق',
|
||||
@@ -35,10 +38,8 @@ const ar = {
|
||||
'Jump Play': 'التشغيل القافز',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay غير متاح',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default ar
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-ar'] = ar
|
||||
}
|
||||
publishLanguage('artplayer-i18n-ar', ar)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const cs = {
|
||||
'Video Info': 'Info o videu',
|
||||
'Close': 'Zavřít',
|
||||
@@ -35,10 +38,8 @@ const cs = {
|
||||
'Jump Play': 'Hra na skok',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay není k dispozici',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default cs
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-cs'] = cs
|
||||
}
|
||||
publishLanguage('artplayer-i18n-cs', cs)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const es = {
|
||||
'Video Info': 'Información del video',
|
||||
'Close': 'Cerrar',
|
||||
@@ -35,10 +38,8 @@ const es = {
|
||||
'Jump Play': 'Saltar',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay no disponible',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default es
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-es'] = es
|
||||
}
|
||||
publishLanguage('artplayer-i18n-es', es)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const fa = {
|
||||
'Video Info': 'اطلاعات ویدیو',
|
||||
'Close': 'بستن',
|
||||
@@ -35,10 +38,8 @@ const fa = {
|
||||
'Jump Play': 'جامپ پلی',
|
||||
'AirPlay': 'ایر پلی',
|
||||
'AirPlay Not Available': 'عدم پشتیبانی از ایرپلی',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default fa
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-fa'] = fa
|
||||
}
|
||||
publishLanguage('artplayer-i18n-fa', fa)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const fr = {
|
||||
'Video Info': 'Informations de la vidéo',
|
||||
'Close': 'Fermer',
|
||||
@@ -35,10 +38,8 @@ const fr = {
|
||||
'Jump Play': 'Continuer',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay non disponible',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default fr
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-fr'] = fr
|
||||
}
|
||||
publishLanguage('artplayer-i18n-fr', fr)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const id = {
|
||||
'Video Info': 'Informasi Video',
|
||||
'Close': 'Tutup',
|
||||
@@ -35,10 +38,8 @@ const id = {
|
||||
'Jump Play': 'Lompat Putar',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay Tidak Tersedia',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default id
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-id'] = id
|
||||
}
|
||||
publishLanguage('artplayer-i18n-id', id)
|
||||
@@ -1,30 +0,0 @@
|
||||
import { mergeDeep } from '../utils'
|
||||
import zhCn from './zh-cn'
|
||||
|
||||
export default class I18n {
|
||||
constructor(art) {
|
||||
this.art = art
|
||||
|
||||
this.languages = {
|
||||
'zh-cn': zhCn,
|
||||
}
|
||||
|
||||
this.language = {}
|
||||
|
||||
this.update(art.option.i18n)
|
||||
}
|
||||
|
||||
init() {
|
||||
const lang = this.art.option.lang.toLowerCase()
|
||||
this.language = this.languages[lang] || {}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this.language[key] || key
|
||||
}
|
||||
|
||||
update(value) {
|
||||
this.languages = mergeDeep(this.languages, value)
|
||||
this.init()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Dictionary, Languages } from './publish'
|
||||
import { has, mergeDeep } from '../utils/property'
|
||||
import zhCn from './zh-cn'
|
||||
|
||||
export interface I18nHost {
|
||||
option: { lang: string, i18n: Languages }
|
||||
}
|
||||
|
||||
export default class I18n {
|
||||
declare art: I18nHost
|
||||
declare languages: Languages
|
||||
declare language: Dictionary
|
||||
|
||||
constructor(art: I18nHost) {
|
||||
this.art = art
|
||||
this.languages = { 'zh-cn': zhCn }
|
||||
this.language = {}
|
||||
this.update(art.option.i18n)
|
||||
}
|
||||
|
||||
init(): void {
|
||||
const lang = this.art.option.lang.toLowerCase()
|
||||
this.language = (has(this.languages, lang) && this.languages[lang]) || {}
|
||||
}
|
||||
|
||||
get(key: string): string {
|
||||
return (has(this.language, key) && this.language[key]) || key
|
||||
}
|
||||
|
||||
update(value: Languages): void {
|
||||
this.languages = mergeDeep(this.languages, value)
|
||||
this.init()
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const pl = {
|
||||
'Video Info': 'Informacje o wideo',
|
||||
'Close': 'Zamknij',
|
||||
@@ -35,10 +38,8 @@ const pl = {
|
||||
'Jump Play': 'Skocz do gry',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay nie jest dostępny',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default pl
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-pl'] = pl
|
||||
}
|
||||
publishLanguage('artplayer-i18n-pl', pl)
|
||||
@@ -0,0 +1,12 @@
|
||||
export type Dictionary = Record<string, string | undefined>
|
||||
export type Languages = Record<string, Dictionary | undefined>
|
||||
|
||||
type LanguageGlobal = 'artplayer-i18n-ar' | 'artplayer-i18n-cs' | 'artplayer-i18n-es' | 'artplayer-i18n-fa' | 'artplayer-i18n-fr' | 'artplayer-i18n-id' | 'artplayer-i18n-pl' | 'artplayer-i18n-ru' | 'artplayer-i18n-tr' | 'artplayer-i18n-vi' | 'artplayer-i18n-zh-cn' | 'artplayer-i18n-zh-tw'
|
||||
|
||||
// Each standalone language keeps its historical browser alias, including ESM.
|
||||
export function publishLanguage(name: LanguageGlobal, value: Dictionary): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
const globals = window as Window & Partial<Record<LanguageGlobal, Dictionary>>
|
||||
globals[name] = value
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const ru = {
|
||||
'Video Info': 'Информация',
|
||||
'Close': 'Закрыть',
|
||||
@@ -35,10 +38,8 @@ const ru = {
|
||||
'Jump Play': 'Перейти',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay недоступен',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default ru
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-ru'] = ru
|
||||
}
|
||||
publishLanguage('artplayer-i18n-ru', ru)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const tr = {
|
||||
'Video Info': 'Video Bilgisi',
|
||||
'Close': 'Kapat',
|
||||
@@ -35,10 +38,8 @@ const tr = {
|
||||
'Jump Play': 'Atla ve Oynat',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay Kullanılamıyor',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default tr
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-tr'] = tr
|
||||
}
|
||||
publishLanguage('artplayer-i18n-tr', tr)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const vi = {
|
||||
'Video Info': 'Thông tin video',
|
||||
'Close': 'Đóng',
|
||||
@@ -35,10 +38,8 @@ const vi = {
|
||||
'Jump Play': 'Nhảy đến đoạn phát',
|
||||
'AirPlay': 'AirPlay',
|
||||
'AirPlay Not Available': 'AirPlay không khả dụng',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default vi
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-vi'] = vi
|
||||
}
|
||||
publishLanguage('artplayer-i18n-vi', vi)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const zhCn = {
|
||||
'Video Info': '统计信息',
|
||||
'Close': '关闭',
|
||||
@@ -35,10 +38,8 @@ const zhCn = {
|
||||
'Jump Play': '跳转播放',
|
||||
'AirPlay': '隔空播放',
|
||||
'AirPlay Not Available': '隔空播放不可用',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default zhCn
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-zh-cn'] = zhCn
|
||||
}
|
||||
publishLanguage('artplayer-i18n-zh-cn', zhCn)
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { Dictionary } from './publish'
|
||||
import { publishLanguage } from './publish'
|
||||
|
||||
const zhTw = {
|
||||
'Video Info': '統計訊息',
|
||||
'Close': '關閉',
|
||||
@@ -35,10 +38,8 @@ const zhTw = {
|
||||
'Jump Play': '跳轉播放',
|
||||
'AirPlay': '隔空播放',
|
||||
'AirPlay Not Available': '隔空播放不可用',
|
||||
}
|
||||
} satisfies Dictionary
|
||||
|
||||
export default zhTw
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window['artplayer-i18n-zh-tw'] = zhTw
|
||||
}
|
||||
publishLanguage('artplayer-i18n-zh-tw', zhTw)
|
||||
Reference in new issue
Block a user