feat: support translation for profile abount

This commit is contained in:
codytseng
2025-06-29 14:13:18 +08:00
parent e89cfc03e9
commit d3093a1c4e
20 changed files with 290 additions and 133 deletions

View File

@@ -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
}
}