improve randomSecword to accept zhCN, enUS, ... as lang

This commit is contained in:
陆柯 2020-02-14 18:18:44 +08:00
parent 5a378f4daa
commit 53b0c4a6c0

View File

@ -324,9 +324,10 @@ module.exports = {
return null
}
,
randomSecword:function(lang){ // Object.keys(Secword.Words) => [ 'CHINESE', 'ENGLISH', 'FRENCH', 'ITALIAN', 'JAPANESE', 'SPANISH' ]
lang = (lang && Secword.Words.hasOwnProperty(lang.toUpperCase())) ? lang.toUpperCase() : 'ENGLISH'
return new Secword(Secword.Words[lang]).phrase
randomSecword:function(lang='ENGLISH'){ // Object.keys(Secword.Words) => [ 'CHINESE', 'ENGLISH', 'FRENCH', 'ITALIAN', 'JAPANESE', 'SPANISH' ]
let language = { zhCN: 'CHINESE', enUS: 'ENGLISH', frFR: 'FRENCH', itIT: 'ITALIAN', jaJP: 'JAPANESE', esES: 'SPANISH' }[lang]
|| (Secword.Words.hasOwnProperty(lang.toUpperCase()) ? lang.toUpperCase() : 'ENGLISH')
return new Secword(Secword.Words[language]).phrase
}
,
randomSeckey:function(option){