Skip to content

Language Settings

DANGER

Given the increasing number of bundled multilingual packs, starting from version 5.1.0, the core code of artplayer.js will no longer include other languages besides Simplified Chinese and English. You need to import the required languages on your own.

WARNING

When a language cannot be matched, English will be displayed by default. For i18n usage, refer to: artplayer/types/i18n.d.ts

Default Languages

The default languages are: en, zh-cn, which do not require manual import.

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

Importing Languages

Language files before packaging are located in: artplayer/src/i18n/*.js. You are welcome to add your language. Packaged language files are located at: artplayer/dist/i18n/*.js

Manually imported languages include: 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',
});

Add Language

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

Modify Language

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'
        },
    },
});