Translation, language detection

This commit is contained in:
Jakob Borg
2014-07-26 22:30:29 +02:00
parent 49cb931572
commit 3b65a58f59
10 changed files with 633 additions and 36 deletions

View File

@@ -106,6 +106,7 @@ func startGUI(cfg config.GUIConfiguration, assetDir string, m *model.Model) erro
getRestMux.HandleFunc("/rest/events", restGetEvents)
getRestMux.HandleFunc("/rest/upgrade", restGetUpgrade)
getRestMux.HandleFunc("/rest/nodeid", restGetNodeID)
getRestMux.HandleFunc("/rest/lang", restGetLang)
// The POST handlers
postRestMux := http.NewServeMux()
@@ -459,6 +460,17 @@ func restGetNodeID(w http.ResponseWriter, r *http.Request) {
}
}
func restGetLang(w http.ResponseWriter, r *http.Request) {
lang := r.Header.Get("Accept-Language")
var langs []string
for _, l := range strings.Split(lang, ",") {
if len(l) >= 2 {
langs = append(langs, l[:2])
}
}
json.NewEncoder(w).Encode(langs)
}
func restPostUpgrade(w http.ResponseWriter, r *http.Request) {
err := upgrade()
if err != nil {