Changeset 30 in code
- Timestamp:
- Feb 10, 2024, 11:39:49 AM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cmd/suwako/main.go
r29 r30 1 // $TheSupernovaDuo: suwako,v 1.5. 4 2024/01/14 21:21:50 yakumo_izuru Exp $1 // $TheSupernovaDuo: suwako,v 1.5.5 2024/01/20 21:07:30 yakumo_izuru Exp $ 2 2 // Command line client for SimplyTranslate, a privacy friendly frontend to other translation engines 3 3 package main … … 43 43 return err 44 44 } 45 conf.engine = cfg.Section("s implytranslate").Key("engine").String()46 conf.instance = cfg.Section("s implytranslate").Key("instance").String()45 conf.engine = cfg.Section("suwako").Key("engine").String() 46 conf.instance = cfg.Section("suwako").Key("instance").String() 47 47 48 48 return nil … … 66 66 67 67 // Load configuration file 68 home, err := os.UserHomeDir()68 config, err := os.UserConfigDir() 69 69 errCheck(err) 70 cfgfile := home + "/.suwako/suwako.conf"70 cfgfile := config + "/suwako/suwako.ini" 71 71 iniLoad(cfgfile) 72 72 … … 83 83 84 84 // Construct the final path to query 85 var queryURL = conf.instance + " ?engine=" + conf.engine + "&from=" + source + "&to=" + target + "&text=" + encInput85 var queryURL = conf.instance + "/api/translate/" + "?engine=" + conf.engine + "&from=" + source + "&to=" + target + "&text=" + encInput 86 86 87 87 // Shoot danmaku to path … … 93 93 _ = json.NewDecoder(resp.Body).Decode(&translate) 94 94 errCheck(err) 95 fmt.Printf("%v\n",translate.Output) 95 if len(translate.Output) == 0 { 96 log.Fatal("There was no output, maybe the server was down?") 97 } else { 98 fmt.Printf("%v\n", translate.Output) 99 } 96 100 }
Note:
See TracChangeset
for help on using the changeset viewer.