diff --git a/config.json b/config.json index ff0976c6..7ce909ec 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,8 @@ "listen_url" : "0.0.0.0:3333", "use_tls" : false, "cert_path" : "gophish_admin.crt", - "key_path" : "gophish_admin.key" + "key_path" : "gophish_admin.key", + "languge": "tr-TR" }, "phish_server" : { "listen_url" : "0.0.0.0:80", @@ -13,5 +14,6 @@ }, "db_name" : "sqlite3", "db_path" : "gophish.db", - "migrations_prefix" : "db/db_" + "migrations_prefix" : "db/db_", + "language": "tr" } diff --git a/config/config.go b/config/config.go index 74588b9f..78d3c137 100644 --- a/config/config.go +++ b/config/config.go @@ -12,6 +12,7 @@ type AdminServer struct { UseTLS bool `json:"use_tls"` CertPath string `json:"cert_path"` KeyPath string `json:"key_path"` + Language string `json:"languge"` } // PhishServer represents the Phish server configuration details diff --git a/controllers/api.go b/controllers/api.go index cb8f08a1..ad4828bd 100644 --- a/controllers/api.go +++ b/controllers/api.go @@ -435,7 +435,7 @@ func API_Pages_Id(w http.ResponseWriter, r *http.Request) { p.UserId = ctx.Get(r, "user_id").(int64) err = models.PutPage(&p) if err != nil { - JSONResponse(w, models.Response{Success: false, Message: util.T("Error updating page: " + err.Error())}, http.StatusInternalServerError) + JSONResponse(w, models.Response{Success: false, Message: util.T("Error updating page:") + " " + err.Error()}, http.StatusInternalServerError) return } JSONResponse(w, p, http.StatusOK) diff --git a/controllers/route.go b/controllers/route.go index e08167cc..bced8891 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -429,7 +429,7 @@ func Settings(w http.ResponseWriter, r *http.Request) { getTemplate(w, "settings").ExecuteTemplate(w, "base", params) case r.Method == "POST": err := auth.ChangePassword(r) - msg := models.Response{Success: true, Message: "Settings Updated Successfully"} + msg := models.Response{Success: true, Message: util.T("Settings Updated Successfully")} if err == auth.ErrInvalidPassword { msg.Message = "Invalid Password" msg.Success = false @@ -480,7 +480,7 @@ func Login(w http.ResponseWriter, r *http.Request) { session.Save(r, w) http.Redirect(w, r, "/", 302) } else { - Flash(w, r, "danger", "Invalid Username/Password") + Flash(w, r, "danger", util.T("Invalid Username/Password")) http.Redirect(w, r, "/login", 302) } } @@ -492,14 +492,14 @@ func Logout(w http.ResponseWriter, r *http.Request) { // Now that we are all registered, we can log the user in session := ctx.Get(r, "session").(*sessions.Session) delete(session.Values, "id") - Flash(w, r, "success", "You have successfully logged out") + Flash(w, r, "success", util.T("You have successfully logged out")) http.Redirect(w, r, "/login", 302) } // Preview allows for the viewing of page html in a separate browser window func Preview(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { - http.Error(w, "Method not allowed", http.StatusBadRequest) + http.Error(w, util.T("Method not allowed"), http.StatusBadRequest) return } fmt.Fprintf(w, "%s", r.FormValue("html")) @@ -509,13 +509,13 @@ func Preview(w http.ResponseWriter, r *http.Request) { func Clone(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if r.Method != "POST" { - http.Error(w, "Method not allowed", http.StatusBadRequest) + http.Error(w, util.T("Method not allowed"), http.StatusBadRequest) return } if url, ok := vars["url"]; ok { Logger.Println(url) } - http.Error(w, "No URL given.", http.StatusBadRequest) + http.Error(w, util.T("No URL given."), http.StatusBadRequest) } func getTemplate(w http.ResponseWriter, tmpl string) *template.Template { diff --git a/gophish.go b/gophish.go index 0b9e0de0..c860ba22 100644 --- a/gophish.go +++ b/gophish.go @@ -35,25 +35,26 @@ import ( "github.com/NYTimes/gziphandler" "github.com/gophish/gophish/auth" - "github.com/gophish/gophish/config" + "./config" "./controllers" "github.com/gophish/gophish/models" "./util" "github.com/gorilla/handlers" - "github.com/nicksnyder/go-i18n/i18n" +// "github.com/nicksnyder/go-i18n/i18n" ) var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile) func main() { // Setup the global variables and settings - i18n.MustLoadTranslationFile("translations/en-US.all.json") err := models.Setup() if err != nil { fmt.Println(err) } wg := &sync.WaitGroup{} wg.Add(1) + + util.ChangeLang(config.Conf.AdminConf.Language) // Start the web servers go func() { defer wg.Done() diff --git a/middleware/middleware.go b/middleware/middleware.go index 5756caa1..018a9b50 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -10,6 +10,7 @@ import ( ctx "github.com/gophish/gophish/context" "github.com/gophish/gophish/models" "github.com/gorilla/csrf" + "../util" ) var CSRFExemptPrefixes = []string{ @@ -36,7 +37,7 @@ func GetContext(handler http.Handler) http.HandlerFunc { // Parse the request form err := r.ParseForm() if err != nil { - http.Error(w, "Error parsing request", http.StatusInternalServerError) + http.Error(w, util.T("Error parsing request"), http.StatusInternalServerError) } // Set the context appropriately here. // Set the session @@ -77,7 +78,7 @@ func RequireAPIKey(handler http.Handler) http.HandlerFunc { } else { u, err := models.GetUserByAPIKey(ak) if err != nil { - JSONError(w, 400, "Invalid API Key") + JSONError(w, 400, util.T("Invalid API Key")) return } r = ctx.Set(r, "user_id", u.Id) diff --git a/static/js/src/app/dashboard.js b/static/js/src/app/dashboard.js index 7aa0709b..1c41cd02 100644 --- a/static/js/src/app/dashboard.js +++ b/static/js/src/app/dashboard.js @@ -135,7 +135,7 @@ $(document).ready(function() { var $point = $(this) value = $point.attr('ct:value') || 0 cidx = $point.attr('ct:meta') - $toolTip.html(campaigns[cidx].name + '
' + T("Successes:" + " " + value.toString() + "%").show(); + $toolTip.html(campaigns[cidx].name + '
' + T("Successes:") + " " + value.toString() + "%").show(); }); $chart.on('mouseleave', '.ct-point', function() { diff --git a/templates/campaign_results.html b/templates/campaign_results.html index 5e5442dd..37bcc19f 100644 --- a/templates/campaign_results.html +++ b/templates/campaign_results.html @@ -32,7 +32,7 @@