Skip to content

Commit

Permalink
feat(translate): toEn for textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Nov 2, 2023
1 parent f85d658 commit ea0d050
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/lib/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,13 @@ export const client = new class Client {
return res.data.text
}

public async translateToEn(content: string): Promise<string> {
this.updateServerUrl()

const res = await this._axios.post(`${this._serverUrl}/service/translate/toEn`, {
text: content
})

return res.data.text
}
}
11 changes: 10 additions & 1 deletion src/lib/components/share/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
$stateStore.input = text
text = ""
await client.send($stateStore.input)
if (get(stateStore).translate) {
const translated = await client.translateToEn($stateStore.input)
if (get(stateStore).debug)
console.log("Translated Text Submit: ", translated)
await client.send(translated)
} else {
await client.send($stateStore.input)
}
}
const handleKeyDown = (event: KeyboardEvent) => {
Expand Down

0 comments on commit ea0d050

Please sign in to comment.