* update i18n

* update i18n
This commit is contained in:
Harvey Zack authored and GitHub committed 2023-08-26 13:22:19 +08:00
1 parent 9ba838aa52
commit e71a683dfd
38 files changed
+12194 -9690

No files matched your search

@@ -0,0 +1,104 @@
# 语言设置
::: danger
鉴于捆绑的多国语言越来越多, 从 `5.1.0` 版本开始, `artplayer.js` 核心代码除了包含 `简体中文` 和 `英文` 外, 不再捆绑其它多国语言, 需要自行导入需要的语言。
:::
:::warning
当无法匹配到语言时, 会默认显示英文, i18n 写法参考: [artplayer/types/i18n.d.ts](https://github.com/zhw2590582/ArtPlayer/blob/master/packages/artplayer/types/i18n.d.ts)
:::
## 默认语言
默认语言有: `en`, `zh-cn`, 无需手动导入
```js{4}
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`, `zh-tw`
::: code-group
```js [import]
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]
<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{4-9}
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'
},
},
});
```
@@ -1012,7 +1012,7 @@ var art = new Artplayer({
- Type: `String`
- Default: `navigator.language.toLowerCase()`
默认显示语言,目前支持:`en`, `zh-cn`, `zh-tw`, `cs`, `pl`, `es`, `fa`, `fr`, `id`, `ru`
默认显示语言,目前支持:`en`, `zh-cn`
<div className="run-code">▶ Run Code</div>
@@ -1024,6 +1024,12 @@ var art = new Artplayer({
});
```
:::warning 更多的语言设置
[/start/i18n.html](/start/i18n.html)
:::
## `i18n`
- Type: `Object`
@@ -1067,9 +1073,9 @@ var art = new Artplayer({
});
```
:::warning i18n 写法参考
:::warning 更多的语言设置
[artplayer/types/i18n.d.ts](https://github.com/zhw2590582/ArtPlayer/blob/master/packages/artplayer/types/i18n.d.ts)
[/start/i18n.html](/start/i18n.html)
:::