mirror of
https://codeberg.org/aryak/mozhi
synced 2024-11-16 18:52:57 +05:30
add support for changing libretransl. instance
This commit is contained in:
parent
0409b30960
commit
e6f60ae68f
5
TODO.md
5
TODO.md
@ -1,12 +1,9 @@
|
||||
# TODO
|
||||
- Create a web interface
|
||||
- Make CLI usable
|
||||
- Interactive/Step-by-step CLI
|
||||
- CI/CD
|
||||
- Support for disabling engines
|
||||
- Ability for user to choose engines they want to use
|
||||
- Fix DDG
|
||||
- Support for changing LibreTranslate instance
|
||||
- Add actual explanations for CLI arguments
|
||||
- Proper Error handling for requests.go
|
||||
- Tell which language Detect Language chose -- Only support for deepl and google is pending
|
||||
- Finish simplytranslate-py compatible API for translations
|
||||
|
@ -1,5 +1,7 @@
|
||||
package utils
|
||||
|
||||
import "os"
|
||||
|
||||
func AutoDetectWatson(query string) (string, error) {
|
||||
json := []byte(`{"text":"` + query + `"}`)
|
||||
watsonOut := PostRequest("https://www.ibm.com/demos/live/watson-language-translator/api/translate/detect", json)
|
||||
@ -10,7 +12,7 @@ func AutoDetectWatson(query string) (string, error) {
|
||||
|
||||
func AutoDetectLibreTranslate(query string) (string, error) {
|
||||
json := []byte(`{"q":"` + query + `"}`)
|
||||
libreTranslateOut := PostRequest("https://translate.argosopentech.com/detect", json)
|
||||
libreTranslateOut := PostRequest(os.Getenv("MOZHI_LIBRETRANSLATE_URL")+"/detect", json)
|
||||
gjsonArr := libreTranslateOut.Get("0.language").Array()
|
||||
answer := gjsonArr[0].String()
|
||||
return answer, nil
|
||||
|
@ -129,7 +129,7 @@ func TranslateLibreTranslate(to string, from string, query string) (LangOut, err
|
||||
}
|
||||
json := []byte(`{"q":"` + query + `","source":"` + from + `","target":"` + to + `"}`)
|
||||
// TODO: Make it configurable
|
||||
libreTranslateOut := PostRequest("https://translate.argosopentech.com/translate", json)
|
||||
libreTranslateOut := PostRequest(os.Getenv("MOZHI_LIBRETRANSLATE_URL")+"/translate", json)
|
||||
gjsonArr := libreTranslateOut.Get("translatedText").Array()
|
||||
var langout LangOut
|
||||
langout.OutputText = gjsonArr[0].String()
|
||||
|
Loading…
Reference in New Issue
Block a user