mirror of https://github.com/gophish/gophish
localization finish-up
parent
363ab116f4
commit
52e30dc0ae
|
@ -3,7 +3,8 @@
|
||||||
"listen_url" : "0.0.0.0:3333",
|
"listen_url" : "0.0.0.0:3333",
|
||||||
"use_tls" : false,
|
"use_tls" : false,
|
||||||
"cert_path" : "gophish_admin.crt",
|
"cert_path" : "gophish_admin.crt",
|
||||||
"key_path" : "gophish_admin.key"
|
"key_path" : "gophish_admin.key",
|
||||||
|
"languge": "tr-TR"
|
||||||
},
|
},
|
||||||
"phish_server" : {
|
"phish_server" : {
|
||||||
"listen_url" : "0.0.0.0:80",
|
"listen_url" : "0.0.0.0:80",
|
||||||
|
@ -13,5 +14,6 @@
|
||||||
},
|
},
|
||||||
"db_name" : "sqlite3",
|
"db_name" : "sqlite3",
|
||||||
"db_path" : "gophish.db",
|
"db_path" : "gophish.db",
|
||||||
"migrations_prefix" : "db/db_"
|
"migrations_prefix" : "db/db_",
|
||||||
|
"language": "tr"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ type AdminServer struct {
|
||||||
UseTLS bool `json:"use_tls"`
|
UseTLS bool `json:"use_tls"`
|
||||||
CertPath string `json:"cert_path"`
|
CertPath string `json:"cert_path"`
|
||||||
KeyPath string `json:"key_path"`
|
KeyPath string `json:"key_path"`
|
||||||
|
Language string `json:"languge"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhishServer represents the Phish server configuration details
|
// PhishServer represents the Phish server configuration details
|
||||||
|
|
|
@ -435,7 +435,7 @@ func API_Pages_Id(w http.ResponseWriter, r *http.Request) {
|
||||||
p.UserId = ctx.Get(r, "user_id").(int64)
|
p.UserId = ctx.Get(r, "user_id").(int64)
|
||||||
err = models.PutPage(&p)
|
err = models.PutPage(&p)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
JSONResponse(w, p, http.StatusOK)
|
JSONResponse(w, p, http.StatusOK)
|
||||||
|
|
|
@ -429,7 +429,7 @@ func Settings(w http.ResponseWriter, r *http.Request) {
|
||||||
getTemplate(w, "settings").ExecuteTemplate(w, "base", params)
|
getTemplate(w, "settings").ExecuteTemplate(w, "base", params)
|
||||||
case r.Method == "POST":
|
case r.Method == "POST":
|
||||||
err := auth.ChangePassword(r)
|
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 {
|
if err == auth.ErrInvalidPassword {
|
||||||
msg.Message = "Invalid Password"
|
msg.Message = "Invalid Password"
|
||||||
msg.Success = false
|
msg.Success = false
|
||||||
|
@ -480,7 +480,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
||||||
session.Save(r, w)
|
session.Save(r, w)
|
||||||
http.Redirect(w, r, "/", 302)
|
http.Redirect(w, r, "/", 302)
|
||||||
} else {
|
} else {
|
||||||
Flash(w, r, "danger", "Invalid Username/Password")
|
Flash(w, r, "danger", util.T("Invalid Username/Password"))
|
||||||
http.Redirect(w, r, "/login", 302)
|
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
|
// Now that we are all registered, we can log the user in
|
||||||
session := ctx.Get(r, "session").(*sessions.Session)
|
session := ctx.Get(r, "session").(*sessions.Session)
|
||||||
delete(session.Values, "id")
|
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)
|
http.Redirect(w, r, "/login", 302)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preview allows for the viewing of page html in a separate browser window
|
// Preview allows for the viewing of page html in a separate browser window
|
||||||
func Preview(w http.ResponseWriter, r *http.Request) {
|
func Preview(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "Method not allowed", http.StatusBadRequest)
|
http.Error(w, util.T("Method not allowed"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "%s", r.FormValue("html"))
|
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) {
|
func Clone(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "Method not allowed", http.StatusBadRequest)
|
http.Error(w, util.T("Method not allowed"), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if url, ok := vars["url"]; ok {
|
if url, ok := vars["url"]; ok {
|
||||||
Logger.Println(url)
|
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 {
|
func getTemplate(w http.ResponseWriter, tmpl string) *template.Template {
|
||||||
|
|
|
@ -35,25 +35,26 @@ import (
|
||||||
|
|
||||||
"github.com/NYTimes/gziphandler"
|
"github.com/NYTimes/gziphandler"
|
||||||
"github.com/gophish/gophish/auth"
|
"github.com/gophish/gophish/auth"
|
||||||
"github.com/gophish/gophish/config"
|
"./config"
|
||||||
"./controllers"
|
"./controllers"
|
||||||
"github.com/gophish/gophish/models"
|
"github.com/gophish/gophish/models"
|
||||||
"./util"
|
"./util"
|
||||||
"github.com/gorilla/handlers"
|
"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)
|
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Setup the global variables and settings
|
// Setup the global variables and settings
|
||||||
i18n.MustLoadTranslationFile("translations/en-US.all.json")
|
|
||||||
err := models.Setup()
|
err := models.Setup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
|
util.ChangeLang(config.Conf.AdminConf.Language)
|
||||||
// Start the web servers
|
// Start the web servers
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
ctx "github.com/gophish/gophish/context"
|
ctx "github.com/gophish/gophish/context"
|
||||||
"github.com/gophish/gophish/models"
|
"github.com/gophish/gophish/models"
|
||||||
"github.com/gorilla/csrf"
|
"github.com/gorilla/csrf"
|
||||||
|
"../util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CSRFExemptPrefixes = []string{
|
var CSRFExemptPrefixes = []string{
|
||||||
|
@ -36,7 +37,7 @@ func GetContext(handler http.Handler) http.HandlerFunc {
|
||||||
// Parse the request form
|
// Parse the request form
|
||||||
err := r.ParseForm()
|
err := r.ParseForm()
|
||||||
if err != nil {
|
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 context appropriately here.
|
||||||
// Set the session
|
// Set the session
|
||||||
|
@ -77,7 +78,7 @@ func RequireAPIKey(handler http.Handler) http.HandlerFunc {
|
||||||
} else {
|
} else {
|
||||||
u, err := models.GetUserByAPIKey(ak)
|
u, err := models.GetUserByAPIKey(ak)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
JSONError(w, 400, "Invalid API Key")
|
JSONError(w, 400, util.T("Invalid API Key"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r = ctx.Set(r, "user_id", u.Id)
|
r = ctx.Set(r, "user_id", u.Id)
|
||||||
|
|
|
@ -135,7 +135,7 @@ $(document).ready(function() {
|
||||||
var $point = $(this)
|
var $point = $(this)
|
||||||
value = $point.attr('ct:value') || 0
|
value = $point.attr('ct:value') || 0
|
||||||
cidx = $point.attr('ct:meta')
|
cidx = $point.attr('ct:meta')
|
||||||
$toolTip.html(campaigns[cidx].name + '<br>' + T("Successes:" + " " + value.toString() + "%").show();
|
$toolTip.html(campaigns[cidx].name + '<br>' + T("Successes:") + " " + value.toString() + "%").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$chart.on('mouseleave', '.ct-point', function() {
|
$chart.on('mouseleave', '.ct-point', function() {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="display:none;" id="campaignResults">
|
<div style="display:none;" id="campaignResults">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="page-header" id="page-title">{{T "Results for campaign.name"}}</h1>
|
<h1 class="page-header" id="page-title">{{T "Results for"}} campaign.name</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="/campaigns" class="btn btn-default">
|
<a href="/campaigns" class="btn btn-default">
|
||||||
|
|
|
@ -130,5 +130,5 @@
|
||||||
"Error fetching groups": "{{T "Error fetching groups"}}"
|
"Error fetching groups": "{{T "Error fetching groups"}}"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/dist/app/users.min.js"></script>
|
<script src="/js/src/app/users.js"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
18
util/util.go
18
util/util.go
|
@ -18,6 +18,7 @@ import (
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gophish/gophish/models"
|
"github.com/gophish/gophish/models"
|
||||||
"github.com/jordan-wright/email"
|
"github.com/jordan-wright/email"
|
||||||
|
@ -26,14 +27,21 @@ import (
|
||||||
|
|
||||||
// Logger is used to send logging messages to stdout.
|
// Logger is used to send logging messages to stdout.
|
||||||
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
||||||
|
var B i18n.TranslateFunc
|
||||||
|
var Lang = "en-US"
|
||||||
|
|
||||||
func T(text string) string{
|
func T(text string) string{
|
||||||
T, _ := i18n.Tfunc("en-US", "en-US")
|
if B == nil {
|
||||||
result := T(text)
|
i18n.MustLoadTranslationFile("translations/" + strings.ToLower(Lang) + ".all.json")
|
||||||
if result == text {
|
B, _ = i18n.Tfunc(Lang)
|
||||||
fmt.Println("NON-TRANSLATION %s", text)
|
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
|
return B(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ChangeLang(lang string) {
|
||||||
|
Lang = lang
|
||||||
|
B = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseMail takes in an HTTP Request and returns an Email object
|
// ParseMail takes in an HTTP Request and returns an Email object
|
||||||
|
|
Loading…
Reference in New Issue