mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-05-01 03:31:41 +00:00
feat: pass useNetwork to translateToLocalByCSV
This commit is contained in:
@@ -1335,7 +1335,7 @@ export default {
|
||||
}
|
||||
if (tag.toLocal) {
|
||||
// 翻译到本地语言
|
||||
promises.push(this.translateToLocalByCSV(tag.value))
|
||||
promises.push(this.translateToLocalByCSV(tag.value, void 0, void 0, useNetwork))
|
||||
} else {
|
||||
// 翻译到英文
|
||||
promises.push(this.translateToEnByCSV(tag.value))
|
||||
|
||||
@@ -161,7 +161,7 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
async translateToLocalByCSV(text, tagCompleteFile = null, reload = false) {
|
||||
async translateToLocalByCSV(text, tagCompleteFile = null, reload = false, useNetwork = false) {
|
||||
let res = await this.getCSV(tagCompleteFile, reload)
|
||||
text = text.trim().toLowerCase()
|
||||
if (res.toLocal.has(text)) {
|
||||
@@ -170,12 +170,15 @@ export default {
|
||||
// 使用 , 分隔
|
||||
const texts = text.split(',').map(t => t.trim())
|
||||
let result = []
|
||||
let needs = []
|
||||
texts.forEach(t => {
|
||||
if (res.toLocal.has(t)) {
|
||||
result.push(res.toLocal.get(t))
|
||||
} else if (useNetwork && t.length) {
|
||||
needs.push(t)
|
||||
}
|
||||
})
|
||||
if (result.length > 0) return result.join(', ')
|
||||
if (result.length > 0 && (!needs.length || texts.length === result.length)) return result.join(', ')
|
||||
}
|
||||
return ''
|
||||
},
|
||||
@@ -215,4 +218,4 @@ export default {
|
||||
return ''
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user