feat: support translation for profile abount
This commit is contained in:
parent
e89cfc03e9
commit
d3093a1c4e
20 changed files with 290 additions and 133 deletions
|
|
@ -13,7 +13,10 @@ class LibreTranslateService {
|
|||
target: string,
|
||||
server?: string,
|
||||
api_key?: string
|
||||
): Promise<string | undefined> {
|
||||
): Promise<string> {
|
||||
if (!text) {
|
||||
return text
|
||||
}
|
||||
if (!server) {
|
||||
throw new Error('LibreTranslate server address is not configured')
|
||||
}
|
||||
|
|
@ -27,7 +30,11 @@ class LibreTranslateService {
|
|||
if (!response.ok) {
|
||||
throw new Error(data.error ?? 'Failed to translate')
|
||||
}
|
||||
return data.translatedText
|
||||
const translatedText = data.translatedText
|
||||
if (!translatedText) {
|
||||
throw new Error('Translation failed')
|
||||
}
|
||||
return translatedText
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue