Skip to content

Commit

Permalink
feat: 更新多语言取值的回退机制
Browse files Browse the repository at this point in the history
从原来默认取空,更改为默认取源多语言的值;这样解决了之前主项目
新增多语言,如果不更新 tb-i18n-loader,值回退到 key 上的问题
  • Loading branch information
靳昌 committed Aug 19, 2019
1 parent 32e4bdc commit 433b9da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (content) {
if (lang === descriptionAs) {
result = util.translate(lang, description)
} else {
result = util.translateLocales(lang, Object.keys(description))
result = util.translateLocales(lang, description)
}
results.push(result)
}
Expand Down
8 changes: 4 additions & 4 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function getLocales (language) {
}

exports.translateLocales = translateLocales
function translateLocales (language, keys) {
function translateLocales (language, description) {
var originLocales = getLocales(language)
var locales = {}
keys.forEach(function (key) {
locales[key] = originLocales[key] || ''
})
for (var key in description) {
locales[key] = originLocales[key] || description[key]
}
return translate(language, locales)
}

Expand Down

0 comments on commit 433b9da

Please sign in to comment.