~yerinalexey/gtranslate

56459bf68069f078f13899631c16236d6546167f — Alexey Yerin 4 months ago 77b101f
web: don't run translation on empty text

This was causing an error when submitting nothing.
1 files changed, 5 insertions(+), 0 deletions(-)

M web.go
M web.go => web.go +5 -0
@@ 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)