Skip to content

语言设置

DANGER

鉴于捆绑的多国语言越来越多, 从 5.1.0 版本开始, artplayer.js 核心代码除了包含 简体中文英文 外, 不再捆绑其它多国语言, 需要自行导入需要的语言。

WARNING

当无法匹配到语言时, 会默认显示英文, i18n 写法参考: artplayer/types/i18n.d.ts

默认语言

默认语言有: en, zh-cn, 无需手动导入

js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    lang: 'zh-cn', // or 'en'
});

导入语言

打包前的语言文件存放于: artplayer/src/i18n/*.js, 欢迎来添加你的语言

打包后的语言文件存放于: artplayer/dist/i18n/*.js

手动导入的语言有: cs, es, fa, fr, id, pl, ru, ar, zh-tw

js
import id from 'artplayer/dist/i18n/id.js';
import zhTw from 'artplayer/dist/i18n/zh-tw.js';

var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    i18n: { 
        id: id,
        'zh-tw': zhTw,
    },
    lang: 'zh-tw',
});
js
<script src="artplayer/dist/i18n/id.js"></script>
<script src="artplayer/dist/i18n/zh-tw.js"></script>

var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    i18n: { 
        id: window['artplayer-i18n-id'],
        'zh-tw': window['artplayer-i18n-zh-tw'],
    },
    lang: 'zh-tw',
});

新增语言

js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    lang: 'your-lang',
    i18n: {
        'your-lang': {
            Play: 'Your Play'
        },
    },
});

修改语言

js
import zhTw from 'artplayer/i18n/zh-tw.js';

var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    i18n: {
        // Change the default language
        'zh-cn': {
            Play: 'Your Play'
        },
        // Change the imported language
        'zh-tw': {
            ...zhTw,
            Play: 'Your Play'
        },
    },
});