Add translation code to handlers
Cette révision appartient à :
Parent
7f4879defd
révision
39b0c4f5df
3 fichiers modifiés avec 9 ajouts et 0 suppressions
|
@ -3,12 +3,15 @@ package router
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ewhal/nyaa/util/languages"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func FaqHandler(w http.ResponseWriter, r *http.Request) {
|
||||
searchForm := NewSearchForm()
|
||||
searchForm.HideAdvancedSearch = true
|
||||
|
||||
languages.SetTranslationFromRequest(faqTemplate, r, "en-us")
|
||||
err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
|
@ -3,6 +3,7 @@ package router
|
|||
import (
|
||||
"github.com/ewhal/nyaa/model"
|
||||
"github.com/ewhal/nyaa/service/torrent"
|
||||
"github.com/ewhal/nyaa/util/languages"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
"github.com/gorilla/mux"
|
||||
"html"
|
||||
|
@ -35,6 +36,8 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
||||
|
||||
languages.SetTranslationFromRequest(homeTemplate, r, "en-us")
|
||||
htv := HomeTemplateVariables{b, NewSearchForm(), navigationTorrents, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||
|
||||
err := homeTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/ewhal/nyaa/util/languages"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,8 @@ func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
searchForm := NewSearchForm()
|
||||
searchForm.HideAdvancedSearch = true
|
||||
|
||||
languages.SetTranslationFromRequest(notFoundTemplate, r, "en-us")
|
||||
err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
Référencer dans un nouveau ticket