summaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorHorus32015-03-23 23:17:51 +0100
committerHorus32015-03-23 23:17:51 +0100
commit05e32cd6787f3f5a48192a5604c5bd3e8e3defc7 (patch)
tree502697af748381e1cfd9cf0d0ea6ba324ad84921 /handler.go
parentac1ee887205d068b7b1c1df690f157dda506e419 (diff)
downloadfreemail-05e32cd6787f3f5a48192a5604c5bd3e8e3defc7.tar.gz
German translation.
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go44
1 files changed, 26 insertions, 18 deletions
diff --git a/handler.go b/handler.go
index c99138e..f84dda0 100644
--- a/handler.go
+++ b/handler.go
@@ -16,18 +16,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- /*
- index := mainTempl.Lookup("index.html")
-
- err = index.ExecuteTemplate(w, "index.html", flash)
- if err != nil {
- log.Println(err)
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- */
-
- err = ExecTemplate("index.html", w, flash)
+ err = ExecTemplate("index", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -47,7 +36,7 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("register.html", w, flash)
+ err = ExecTemplate("register", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -115,7 +104,7 @@ func AboutHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("about.html", w, flash)
+ err = ExecTemplate("about", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -135,7 +124,7 @@ func ServerHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("server.html", w, flash)
+ err = ExecTemplate("server", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -155,7 +144,7 @@ func HowtoHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("howto.html", w, flash)
+ err = ExecTemplate("howto", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -175,7 +164,7 @@ func UserHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("user.html", w, flash)
+ err = ExecTemplate("user", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -195,7 +184,7 @@ func PasswordHandler(w http.ResponseWriter, r *http.Request) {
flash.Success = session.Flashes("success")
session.Save(r, w)
- err = ExecTemplate("password.html", w, flash)
+ err = ExecTemplate("password", w, r, flash)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -246,3 +235,22 @@ func ChangePasswordHandler(w http.ResponseWriter, r *http.Request) {
session.Save(r, w)
http.Redirect(w, r, "/user", 302)
}
+
+func ChangeLocaleHandler(w http.ResponseWriter, r *http.Request) {
+ err := r.ParseForm()
+ if err != nil {
+ log.Panic(err)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ locale := r.URL.Query().Get("to")
+
+ if len(locale) == 0 {
+ http.Redirect(w, r, "/", 302)
+ return
+ }
+ cookie := http.Cookie{Name: "lang", Value: locale}
+ http.SetCookie(w, &cookie)
+ http.Redirect(w, r, "/", 302)
+}