Add note and speaker to message data
This commit is contained in:
@@ -16,6 +16,8 @@ async function sendPofile(arg:sendFileArg){
|
|||||||
|
|
||||||
let result = ''
|
let result = ''
|
||||||
let msgId = ''
|
let msgId = ''
|
||||||
|
let note = ''
|
||||||
|
let speaker = ''
|
||||||
let parseMode = 0
|
let parseMode = 0
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
let currentChar = db.characters[get(selectedCharID)]
|
let currentChar = db.characters[get(selectedCharID)]
|
||||||
@@ -29,10 +31,16 @@ async function sendPofile(arg:sendFileArg){
|
|||||||
result += '\n'
|
result += '\n'
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const id = msgId
|
let text = msgId
|
||||||
|
if(speaker !== ''){
|
||||||
|
text = `Speaker: ${speaker}\n${text}`
|
||||||
|
}
|
||||||
|
if(note !== ''){
|
||||||
|
text = `Note: ${note}\n${text}`
|
||||||
|
}
|
||||||
currentChat.message.push({
|
currentChat.message.push({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
data: id
|
data: text
|
||||||
})
|
})
|
||||||
currentChar.chats[currentChar.chatPage] = currentChat
|
currentChar.chats[currentChar.chatPage] = currentChat
|
||||||
db.characters[get(selectedCharID)] = currentChar
|
db.characters[get(selectedCharID)] = currentChar
|
||||||
@@ -48,13 +56,22 @@ async function sendPofile(arg:sendFileArg){
|
|||||||
return `"${str.replaceAll('"', '\\"')}"`
|
return `"${str.replaceAll('"', '\\"')}"`
|
||||||
}).join('\n')
|
}).join('\n')
|
||||||
result += `msgstr ""\n${msgStr}\n\n`
|
result += `msgstr ""\n${msgStr}\n\n`
|
||||||
|
note = ''
|
||||||
|
speaker = ''
|
||||||
msgId = ''
|
msgId = ''
|
||||||
if(isTauri){
|
if(isTauri){
|
||||||
await downloadFile('translated.po', result)
|
await downloadFile('translated.po', result)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if(line.startsWith('#. Note =')){
|
||||||
|
note = line.replace('#. Notes =', '').trim()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if(line.startsWith('#. Speaker =')){
|
||||||
|
speaker = line.replace('#. Speaker =', '').trim()
|
||||||
|
continue
|
||||||
|
}
|
||||||
if(line.startsWith('msgid')){
|
if(line.startsWith('msgid')){
|
||||||
parseMode = 0
|
parseMode = 0
|
||||||
msgId = line.replace('msgid ', '').trim().replaceAll('\\"', '♠#').replaceAll('"', '').replaceAll('♠#', '\\"')
|
msgId = line.replace('msgid ', '').trim().replaceAll('\\"', '♠#').replaceAll('"', '').replaceAll('♠#', '\\"')
|
||||||
|
|||||||
Reference in New Issue
Block a user