web: don't run translation on empty text
This was causing an error when submitting nothing.
This commit is contained in:
parent
77b101f877
commit
56459bf680
5
web.go
5
web.go
|
@ -24,6 +24,11 @@ func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func
|
|||
to := req.FormValue("to")
|
||||
text := req.FormValue("text")
|
||||
|
||||
if text == "" {
|
||||
tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, ""})
|
||||
return
|
||||
}
|
||||
|
||||
translation, err := Translate(settings, from, to, text)
|
||||
if err != nil {
|
||||
writeError(w, 500, err)
|
||||
|
|
Loading…
Reference in New Issue