mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-05-01 03:31:41 +00:00
fix: translateToLocalByGroupTag
This commit is contained in:
@@ -1324,7 +1324,7 @@ export default {
|
||||
|
||||
let translateByCSV = (tags) => {
|
||||
// 开启了使用tagcomplete翻译
|
||||
console.log('translateByCSV', tags.map(tag => tag.value))
|
||||
console.log('translateByCSV', tags.map(tag => tag.value), { useNetwork })
|
||||
let promises = []
|
||||
tags.forEach(tag => {
|
||||
// 是否被括号包裹
|
||||
@@ -1377,7 +1377,7 @@ export default {
|
||||
|
||||
let translateByGroupTags = (tags) => {
|
||||
// 开启了使用关键词组翻译
|
||||
console.log('translateByGroupTags', tags.map(tag => tag.value))
|
||||
console.log('translateByGroupTags', tags.map(tag => tag.value), { useNetwork })
|
||||
let promises = []
|
||||
tags.forEach(tag => {
|
||||
// 是否被括号包裹
|
||||
@@ -1388,10 +1388,10 @@ export default {
|
||||
}
|
||||
if (tag.toLocal) {
|
||||
// 翻译到本地语言
|
||||
promises.push(this.translateToLocalByGroupTags(tag.value))
|
||||
promises.push(this.translateToLocalByGroupTags(tag.value, useNetwork))
|
||||
} else {
|
||||
// 翻译到英文
|
||||
promises.push(this.translateToEnByGroupTags(tag.value))
|
||||
promises.push(this.translateToEnByGroupTags(tag.value, useNetwork))
|
||||
}
|
||||
})
|
||||
Promise.allSettled(promises).then(results => {
|
||||
|
||||
@@ -178,7 +178,7 @@ export default {
|
||||
needs.push(t)
|
||||
}
|
||||
})
|
||||
if (result.length > 0 && (!needs.length || texts.length === result.length)) return result.join(', ')
|
||||
if (result.length > 0 && !needs.length) return result.join(', ')
|
||||
}
|
||||
return ''
|
||||
},
|
||||
@@ -190,8 +190,8 @@ export default {
|
||||
}
|
||||
return ''
|
||||
},
|
||||
async translateToLocalByGroupTags(text) {
|
||||
console.log(text)
|
||||
async translateToLocalByGroupTags(text, useNetwork = false) {
|
||||
console.log('translateToLocalByGroupTags', text)
|
||||
text = text.trim().toLowerCase()
|
||||
if (this.groupTagsTranslateCache.toLocal.has(text)) {
|
||||
let value = this.groupTagsTranslateCache.toLocal.get(text)
|
||||
@@ -200,13 +200,16 @@ export default {
|
||||
// 使用 , 分隔
|
||||
const texts = text.split(',').map(t => t.trim())
|
||||
let result = []
|
||||
let needs = []
|
||||
texts.forEach(t => {
|
||||
if (this.groupTagsTranslateCache.toLocal.has(t)) {
|
||||
let value = this.groupTagsTranslateCache.toLocal.get(t)
|
||||
result.push(value.join(' / '))
|
||||
} else if (useNetwork && t.length) {
|
||||
needs.push(t)
|
||||
}
|
||||
})
|
||||
if (result.length > 0) return result.join(', ')
|
||||
if (result.length > 0 && !needs.length) return result.join(', ')
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user