add language selector to admin

This commit is contained in:
Harvey Tindall
2021-01-15 13:48:18 +00:00
committed by Harvey Tindall
parent 2d2727f7e8
commit 5e8d7944bd
6 changed files with 40 additions and 24 deletions
+9 -2
View File
@@ -1237,9 +1237,16 @@ func (app *appContext) Logout(gc *gin.Context) {
// @Router /lang [get]
// @tags Other
func (app *appContext) GetLanguages(gc *gin.Context) {
page := gc.Param("page")
resp := langDTO{}
for key, lang := range app.storage.lang.Form {
resp[key] = lang["meta"].(map[string]interface{})["name"].(string)
if page == "form" {
for key, lang := range app.storage.lang.Form {
resp[key] = lang["meta"].(map[string]interface{})["name"].(string)
}
} else if page == "admin" {
for key, lang := range app.storage.lang.Admin {
resp[key] = lang["meta"].(map[string]interface{})["name"].(string)
}
}
if len(resp) == 0 {
respond(500, "Couldn't get languages", gc)