mirror of
https://github.com/DIYgod/DPlayer
synced 2024-11-23 04:05:28 +00:00
src/options:
Browser langage support IE6 ~ IE8 use lowercase to prevent case typo from user src/i18n.js: Use language-code to support more language trans
This commit is contained in:
parent
6c50dc2dad
commit
8eb07af09a
63
src/i18n.js
63
src/i18n.js
@ -1,4 +1,29 @@
|
||||
const tranZH = {
|
||||
/*
|
||||
W3C def language codes is :
|
||||
language-code = primary-code ( "-" subcode )
|
||||
primary-code ISO 639-1 ( the names of language with 2 code )
|
||||
subcode ISO 3166 ( the names of countries )
|
||||
|
||||
NOTE: use lowercase to prevent case typo from user!
|
||||
Use this as shown below..... */
|
||||
|
||||
module.exports = function (lang) {
|
||||
this.lang = lang;
|
||||
this.tran = (text) => {
|
||||
if (this.lang === 'en-us') {
|
||||
return text;
|
||||
}
|
||||
else if (
|
||||
// add language-code list here
|
||||
this.lang === 'zh-cn' ||
|
||||
this.lang === 'zh-tw'
|
||||
) { return tranTxt[this.lang][text]; }
|
||||
};
|
||||
};
|
||||
|
||||
// add translation text here
|
||||
const tranTxt = {
|
||||
"zh-cn" : {
|
||||
'Danmaku is loading': '弹幕加载中',
|
||||
'Top': '顶部',
|
||||
'Bottom': '底部',
|
||||
@ -19,19 +44,27 @@ const tranZH = {
|
||||
'Switching to': '正在切换至',
|
||||
'Switched to': '已经切换至',
|
||||
'quality': '画质',
|
||||
'FF to': '快进至',
|
||||
'REW to': '快退至',
|
||||
'Volume': '音量'
|
||||
};
|
||||
|
||||
module.exports = function (lang) {
|
||||
this.lang = lang;
|
||||
this.tran = (text) => {
|
||||
if (this.lang === 'en') {
|
||||
return text;
|
||||
},
|
||||
"zh-tw" : {
|
||||
'Danmaku is loading': '彈幕加載中',
|
||||
'Top': '頂部',
|
||||
'Bottom': '底部',
|
||||
'Rolling': '滾動',
|
||||
'Input danmaku, hit Enter': '輸入彈幕,Enter 發送',
|
||||
'About author': '關於作者',
|
||||
'DPlayer feedback': '播放器意見反饋',
|
||||
'About DPlayer': '關於 DPlayer 播放器',
|
||||
'Loop': '循環播放',
|
||||
'Speed': '速度',
|
||||
'Opacity for danmaku': '彈幕透明度',
|
||||
'Normal': '正常',
|
||||
'Please input danmaku content!': '請輸入彈幕内容啊!',
|
||||
'Set danmaku color': '設置彈幕顏色',
|
||||
'Set danmaku type': '設置彈幕類型',
|
||||
'Danmaku': '彈幕',
|
||||
'This video fails to load': '視頻加載失敗',
|
||||
'Switching to': '正在切換至',
|
||||
'Switched to': '已經切換至',
|
||||
'quality': '畫質',
|
||||
}
|
||||
else if (this.lang === 'zh') {
|
||||
return tranZH[text];
|
||||
}
|
||||
};
|
||||
};
|
@ -13,7 +13,7 @@ module.exports = (option) => {
|
||||
autoplay: false,
|
||||
theme: '#b7daff',
|
||||
loop: false,
|
||||
lang: navigator.language.indexOf('zh') !== -1 ? 'zh' : 'en',
|
||||
lang: (navigator.language || navigator.browserLanguage).toLowerCase().indexOf('zh-cn') !== -1 ? 'zh-cn' : 'en-us',
|
||||
screenshot: false,
|
||||
hotkey: true,
|
||||
preload: 'auto',
|
||||
@ -53,5 +53,9 @@ module.exports = (option) => {
|
||||
option.video.url = [option.video.quality[option.video.defaultQuality].url];
|
||||
}
|
||||
|
||||
if (option.lang) {
|
||||
option.lang.toLowerCase();
|
||||
}
|
||||
|
||||
return option;
|
||||
};
|
Loading…
Reference in New Issue
Block a user