feat: Automatic comment translation using DeepL
Some checks failed
Build and Push to Docker Hub on push to any branch / docker (push) Has been cancelled

This commit is contained in:
Noah 2025-10-13 06:08:26 +02:00
parent c6c7480493
commit 1e94b1fc1e
No known key found for this signature in database
GPG key ID: D2A7E2C8F77E0430
10 changed files with 250 additions and 20 deletions

35
deepL/types.go Normal file
View file

@ -0,0 +1,35 @@
package deepl
import (
"net/http"
)
type translateResponse struct {
Translations []struct {
DetectedSourceLanguage string `json:"detected_source_language"`
Text string `json:"text"`
} `json:"translations"`
}
type translateRequest struct {
Text []string `json:"text"`
TargetLang string `json:"target_lang"`
}
type languagesResponse []struct {
Language string `json:"language"`
Name string `json:"name"`
SupportsFormality bool `json:"supports_formality"` //unused
}
type apiClient struct {
authKey string
baseURL string
httpClient *http.Client
}
const (
baseURLPro = "https://api.deepl.com/v2"
baseURLFree = "https://api-free.deepl.com/v2"
)