西瓜播放器 HTML5 video video.js 播放器 HTML5播放器 mp4 hls hls.js flv flv.js dash dash.js 无缝切换

i18n

Hint

3.0.0-alpha.41 and later versions available

All xgplayer plugins provide four languages, namely Simplified Chinese, Traditional Chinese, English and Japanese, and provide users with the expansion ability to add new language packs and default languages. Chinese and English are packaged by default, and Japanese and traditional Chinese need to be imported and added from the es directory

Capabilities:

  • Custom language pack
  • Extend/Modify existing language pack
  • Switch all the builtin plugin languages of the initialized instance with one button
  • One-button switch, and provide static interface

I18N.use(Object)

Add a new language pack

The data structure of the language pack is as follows. For detailed definitions, refer to Preset language list

{
  LANG: 'custom', // Lang to be defined
  TEXT: {...} // Lang list
}

demo

/**
 * UMD package:
 * const I18N = window.Player.I18N
 */
import Player, { I18N } from 'xgplayer'
const CUSTOM_LANG = {
  LANG: 'custom', // Lang to be defined
  // Lang list
  TEXT: {
    HAVE_NOTHING:'没有关于音频/视频是否就绪的信息',
    ...
  }
}

// use custom lang package
I18N.use(CUSTOM_LANG)

// Initialize default custom lang
player = new Player({
  lang: 'custom'
  ...
})

// Switch lang after created a player instance
player.lang = 'custom'

/**
 * Get the list of currently integrated lang packs
 * {
 *   en: {...},
 *   zh: {...}
 * }
 */
I18N.lang

/**
 * Get the list of languages currently integrated
 * ["en", "zh-cn"]
 */
I18N.langKeys

I18N.extend(Object)

Extend the configuration item for language package

import Player, {I18N} from 'xgplayer'
const CUSTOM_LANG = [{
  LANG: 'zh',
  TEXT: '这是扩展语言项目'
}, {
  LANG: 'en',
  TEXT: 'this is an language item'
}]

// Extended Language Pack
I18N.extend(CUSTOM_LANG)

player.lang

import Player from 'xgplayer'
const player1 = new Player({
  lang: 'zh',
  ...
})

// Switch lang after created a player instance
player1.lang = 'en'

Predefined language packs

At present, only Simplified Chinese and English are predefined language packs by default. If you want to use the predefined language packs Japanese and Traditional Chinese, you can reference them from the es/lang directory, us as the following:

import Player, {I18N} from 'xgplayer'
// jp
import JP from 'xgplayer/es/lang/jp'
// zh-hk
import ZH_HK from 'xgplayer/es/lang/zh-hk'

// use custom lang pack
I18N.use(JP)
I18N.use(ZH_HK)

Lang Defined[Chinese/English]

keyzhen
HAVE_NOTHING没有关于音频/视频是否就绪的信息There is no information on whether audio/video is ready
HAVE_METADATA音频/视频的元数据已就绪Audio/video metadata is ready
HAVE_CURRENT_DATA关于当前播放位置的数据是可用的,但没有足够的数据来播放下一帧/毫秒Data about the current play location is available, but there is not enough data to play the next frame/millisecond
HAVE_FUTURE_DATA当前及至少下一帧的数据是可用的Current and at least one frame of data is available
HAVE_ENOUGH_DATA可用数据足以开始播放The available data is sufficient to start playing
NETWORK_EMPTY音频/视频尚未初始化Audio/video has not been initialized
NETWORK_IDLE音频/视频是活动的且已选取资源,但并未使用网络Audio/video is active and has been selected for resources, but no network is used
NETWORK_LOADING浏览器正在下载数据The browser is downloading the data
NETWORK_NO_SOURCE未找到音频/视频来源No audio/video source was found
MEDIA_ERR_ABORTED取回过程被用户中止The fetch process is aborted by the user
MEDIA_ERR_NETWORK当下载时发生错误An error occurred while downloading
MEDIA_ERR_DECODE当解码时发生错误An error occurred while decoding
MEDIA_ERR_SRC_NOT_SUPPORTED不支持的音频/视频格式Audio/video is not supported
REPLAY重播Replay
ERROR网络连接似乎出现了问题Network is offline
PLAY_TIPS播放Play
PAUSE_TIPS暂停Pause
PLAYNEXT_TIPS下一集Play next
DOWNLOAD_TIPS下载Download
ROTATE_TIPS旋转Rotate
RELOAD_TIPS重新载入Reload
FULLSCREEN_TIPS进入全屏Fullscreen
EXITFULLSCREEN_TIPS退出全屏Exit fullscreen
CSSFULLSCREEN_TIPS进入样式全屏Cssfullscreen
EXITCSSFULLSCREEN_TIPS退出样式全屏Exit cssfullscreen
TEXTTRACK字幕Caption
PIP画中画PIP
SCREENSHOT截图Screenshot
LIVE正在直播LIVE
OFF关闭Off
OPEN开启Open
MINI_DRAG点击按住可拖动视频Click and hold to drag
MINISCREEN小屏幕Miniscreen
REFRESH_TIPS请试试Please Try
REFRESH刷新Refresh