diff --git a/auth/assets/templates/authorized-clients.html.tpl b/auth/assets/templates/authorized-clients.html.tpl index 873dfd7aa..15c55a579 100644 --- a/auth/assets/templates/authorized-clients.html.tpl +++ b/auth/assets/templates/authorized-clients.html.tpl @@ -14,7 +14,7 @@
{{ .Name }}
- {{ tr "authorized-clients.template.authorized" }} + {{ tr "authorized-clients.template.list.authorized-on" }}
{{ else }}
- {{ tr "authorized-clients.template.no-auth-clients" }} + {{ tr "authorized-clients.template.list.empty" }}
{{ end }} diff --git a/auth/assets/templates/logout.html.tpl b/auth/assets/templates/logout.html.tpl index adb6adc9f..c0c5a03f1 100644 --- a/auth/assets/templates/logout.html.tpl +++ b/auth/assets/templates/logout.html.tpl @@ -7,12 +7,12 @@
{{ else }}
- {{ tr "logout.log-out" }} + {{ tr "logout.template.log-out" }}
{{ end }}
- Click here to Log in + {{ tr "logout.template.log-in" "link" .link }}
diff --git a/auth/assets/templates/mfa-totp-disable.html.tpl b/auth/assets/templates/mfa-totp-disable.html.tpl index 2f82ab2a8..f63dc5933 100644 --- a/auth/assets/templates/mfa-totp-disable.html.tpl +++ b/auth/assets/templates/mfa-totp-disable.html.tpl @@ -1,13 +1,13 @@ {{ template "inc_header.html.tpl" set . "hideNav" true }}
-

{{ tr "mfa_totp_disable.template.title" }}

+

{{ tr "mfa-totp-disable.template.title" }}

- {{ tr "mfa_totp_disable.template.form.title" }} + {{ tr "mfa-totp-disable.template.instructions" }} {{ if .form.error }}
diff --git a/auth/assets/templates/mfa-totp.html.tpl b/auth/assets/templates/mfa-totp.html.tpl index 714d86fe0..f45d91ef1 100644 --- a/auth/assets/templates/mfa-totp.html.tpl +++ b/auth/assets/templates/mfa-totp.html.tpl @@ -1,10 +1,10 @@ {{ template "inc_header.html.tpl" set . "hideNav" true }}
-

Configure two-factor authentication with TOTP

+

{{ tr "mfa-totp.template.title" }}

{{ if .enforced }}

- {{ tr "mfa_totp.template.paragraph" }} + {{ tr "mfa-totp.template.enforced" }}

{{ end }} @@ -20,7 +20,7 @@ method="POST" action="{{ links.MfaTotpNewSecret }}" > - {{ tr "mfa_totp.template.form.title-2" }} + {{ tr "mfa-totp.template.form.title" }} {{ if .form.error }}

- {{ tr "mfa_totp.template.form.paragraph-one" }} -

-

- {{ tr "mfa_totp.template.form.paragraph-two" }} -

-

- {{ tr "mfa_totp.template.form.paragraph-three" }} + {{ tr "mfa-totp.template.instructions" }}

- - {{ template "inc_footer.html.tpl" . }} diff --git a/auth/assets/templates/mfa.html.tpl b/auth/assets/templates/mfa.html.tpl index 94ef85f67..6c0e5cbad 100644 --- a/auth/assets/templates/mfa.html.tpl +++ b/auth/assets/templates/mfa.html.tpl @@ -8,7 +8,7 @@ method="POST" action="{{ links.Mfa }}" > -
{{ tr "mfa.template.form-1.title" }}
+
{{ tr "mfa.template.email.instructions" }}
{{ if .form.emailOtpError }} - {{ tr "mfa.buttons.resend" }} + {{ tr "mfa.template.email.resend" }} {{ else if not .emailOtpDisabled }}

- {{ tr "mfa.paragraph-1" }} + {{ tr "mfa.template.email.confirmed" }}

{{ end }} @@ -63,7 +63,7 @@ method="POST" action="{{ links.Mfa }}" > -
{{ tr "mfa.template.form-2.title" }}
+
{{ tr "mfa.template.totp.instructions" }}
{{ if .form.totpError }} {{ else if not .totpDisabled }}

- {{ tr "mfa.paragraph-2" }} + {{ tr "mfa.template.totp.confirmed" }}

{{ end }} diff --git a/auth/assets/templates/oauth2-authorize-client.html.tpl b/auth/assets/templates/oauth2-authorize-client.html.tpl index f7bdbdd15..6bad6019c 100644 --- a/auth/assets/templates/oauth2-authorize-client.html.tpl +++ b/auth/assets/templates/oauth2-authorize-client.html.tpl @@ -3,11 +3,11 @@
{{ if .invalidUser }} {{ end }} -

{{ tr "oauth2_authorize_client.template.title" }} "{{ coalesce .client.Name }}"

+

{{ tr "oauth2-authorize-client.template.title" }} "{{ coalesce .client.Name }}"

{{ .csrfField }}

- {{ tr "oauth2_authorize_client.template.form.greeting-paragraph" }} {{ coalesce .user.Name .user.Handle .user.Email }}, + {{ tr "oauth2-authorize-client.template.form.greeting-paragraph" }} {{ coalesce .user.Name .user.Handle .user.Email }},

- {{ .client.Name }} {{ tr "oauth2_authorize_client.template.form.question-for-client" }} + {{ .client.Name }} {{ tr "oauth2-authorize-client.template.form.question-for-client" }}

@@ -30,7 +30,7 @@ class="btn btn-{{ if .disabled }}secondary{{ else }}primary{{ end }} btn-lg m-2" style="width:250px;" > - {{ tr "oauth2_authorize_client.template.form.button-allow" }} + {{ tr "oauth2-authorize-client.template.form.buttons.allow" }}

- {{ tr "oauth2_authorize_client.template.form.mistake" }} {{ tr "oauth2_authorize_client.template.form.log-out-link" }}. + {{ tr "oauth2-authorize-client.template.links.mistake" }}
diff --git a/auth/assets/templates/password-reset-requested.html.tpl b/auth/assets/templates/password-reset-requested.html.tpl index dcd2d9bfc..4183bbffc 100644 --- a/auth/assets/templates/password-reset-requested.html.tpl +++ b/auth/assets/templates/password-reset-requested.html.tpl @@ -1,13 +1,11 @@ {{ template "inc_header.html.tpl" . }}
-

{{ tr "password_reset_requested.template.title" }}

+

{{ tr "password-reset-requested.template.title" }}

- {{ tr "password_reset_requested.template.new-account-link" }} - or - {{ tr "password_reset_requested.template.login" }} + {{ tr "password-reset-requested.template.links" "signup" links.Signup "login" links.Login }}
{{ template "inc_footer.html.tpl" . }} diff --git a/auth/assets/templates/pending-email-confirmation.html.tpl b/auth/assets/templates/pending-email-confirmation.html.tpl index f6e76cdd5..0d7da5aa0 100644 --- a/auth/assets/templates/pending-email-confirmation.html.tpl +++ b/auth/assets/templates/pending-email-confirmation.html.tpl @@ -1,13 +1,11 @@ {{ template "inc_header.html.tpl" . }}
-

{{ tr "pending_email_confirmation.template.title" }}

+

{{ tr "pending-email-confirmation.template.title" }}

- {{ tr "pending_email_confirmation.template.new-acc-link" }} - or - {{ tr "pending_email_confirmation.template.login" }} + {{ tr "pending-email-confirmation.template.links" "signup" links.Signup "login" links.Login }}
{{ template "inc_footer.html.tpl" . }} diff --git a/auth/assets/templates/profile.html.tpl b/auth/assets/templates/profile.html.tpl index e4f31faad..3ed689ff0 100644 --- a/auth/assets/templates/profile.html.tpl +++ b/auth/assets/templates/profile.html.tpl @@ -21,15 +21,15 @@ class="form-control" name="email" id="profileFormEmail" - placeholder="{{ tr "profile.template.form.email.placeholder" }}" + placeholder="email@domain.ltd" autocomplete="username" readonly value="{{ .form.email }}" - aria-label="{{ tr "profile.template.form.email.aria-label" }}"> + aria-label="{{ tr "profile.template.form.email.label" }}">
{{ if .emailConfirmationRequired }}
- {{ tr "profile.template.form.text-danger-1" }} {{ tr "profile.template.form.text-danger-2" }} + {{ tr "profile.template.form.email.resend-confirmation-link" "link" links.PendingEmailConfirmation }}
{{ end }}
@@ -45,7 +45,7 @@ placeholder="{{ tr "profile.template.form.name.placeholder" }}" value="{{ .form.name }}" autocomplete="name" - aria-label="{{ tr "profile.template.form.name.aria-label" }}"> + aria-label="{{ tr "profile.template.form.name.label" }}">
@@ -58,7 +58,7 @@ placeholder="{{ tr "profile.template.form.handle.placeholder" }}" value="{{ .form.handle }}" autocomplete="handle" - aria-label="{{ tr "profile.template.form.handle.aria-label" }}"> + aria-label="{{ tr "profile.template.form.handle.label" }}">
@@ -66,7 +66,7 @@ type="submit" class="btn btn-primary btn-block btn-lg" > - {{ tr "profile.template.form.button" }} + {{ tr "profile.template.form.buttons.submit" }}
diff --git a/auth/assets/templates/request-password-reset.html.tpl b/auth/assets/templates/request-password-reset.html.tpl index bca3744fa..a42a13285 100644 --- a/auth/assets/templates/request-password-reset.html.tpl +++ b/auth/assets/templates/request-password-reset.html.tpl @@ -1,6 +1,6 @@ {{ template "inc_header.html.tpl" . }}
-

{{ tr "request_password_reset.template.title" }}

+

{{ tr "request-password-reset.template.title" }}

+ aria-label="{{ tr "request-password-reset.template.form.email.label" }}">
- +
- {{ tr "request_password_reset.template.new-acc-link" }} - {{ tr "request_password_reset.template.or" }} - {{ tr "request_password_reset.template.login" }} + {{ tr "request-password-reset.template.links" "signup" links.Signup "login" links.Login }}
{{ template "inc_footer.html.tpl" . }} diff --git a/auth/assets/templates/reset-password.html.tpl b/auth/assets/templates/reset-password.html.tpl index e2250a296..0260ae904 100644 --- a/auth/assets/templates/reset-password.html.tpl +++ b/auth/assets/templates/reset-password.html.tpl @@ -1,6 +1,6 @@ {{ template "inc_header.html.tpl" . }}
-

{{ tr "reset_password.template.title" }}

+

{{ tr "reset-password.template.title" }}

+ aria-label="{{ tr "reset-password.template.form.emaillabel" }}">
+ placeholder="{{ tr "reset-password.template.form.new-password.placeholder" }}" + aria-label="{{ tr "reset-password.template.form.new-passwordlabel" }}">
- +
diff --git a/auth/assets/templates/scenarios.yaml b/auth/assets/templates/scenarios.yaml index e682b81a9..ded9829f0 100644 --- a/auth/assets/templates/scenarios.yaml +++ b/auth/assets/templates/scenarios.yaml @@ -110,7 +110,8 @@ mfa-totp-disable: error: "There was an error..." logout: - Default: {} + Default: + link: '#' With error: form: error: "There was an error..." diff --git a/auth/assets/templates/security.html.tpl b/auth/assets/templates/security.html.tpl index 30a15b6bc..7fa3c17ab 100644 --- a/auth/assets/templates/security.html.tpl +++ b/auth/assets/templates/security.html.tpl @@ -8,19 +8,19 @@ > {{ if .settings.LocalEnabled }} -
{{ tr "security.template.form.title" }}
- {{ tr "security.template.form.passw-change" }} +
{{ tr "security.template.password.title" }}
+ {{ tr "security.template.password.change-link" }} {{ end }}
{{ .csrfField }} -
{{ tr "security.template.security.title" }}
+
{{ tr "security.template.mfa.title" }}
{{ if or .settings.MultiFactor.TOTP.Enabled .settings.MultiFactor.EmailOTP.Enabled }} {{ if .settings.MultiFactor.TOTP.Enabled }}
-
{{ tr "security.template.security.description" }}
+
{{ tr "security.template.mfa.totp.title" }}
{{ if .totpEnforced }} @@ -29,18 +29,18 @@ {{ end }} {{ if .totpEnforced }} - {{ tr "security.template.security.req-login" }} + {{ tr "security.template.mfa.totp.enforced" }} {{ else }} - {{ tr "security.template.security.disable" }} + {{ tr "security.template.mfa.totp.disabled" }} {{ end }}
{{ if .totpEnforced }} {{ if not .settings.MultiFactor.TOTP.Enforced }} - + {{ end }} {{ else }} - + {{ end }}
@@ -49,7 +49,7 @@ {{ if .settings.MultiFactor.EmailOTP.Enabled }}
-
{{ tr "security.template.aditional-security.title" }}
+
{{ tr "security.template.mfa.email.title" }}
{{ if .emailOtpEnforced }} @@ -58,18 +58,18 @@ {{ end }} {{ if .emailOtpEnforced }} - {{ tr "security.template.aditional-security.email-otp-enforced" }} + {{ tr "security.template.mfa.email.enforced" }} {{ else }} - {{ tr "security.template.aditional-security.disable" }} + {{ tr "security.template.mfa.email.disabled" }} {{ end }}
{{ if .emailOtpEnforced }} {{ if not .settings.MultiFactor.EmailOTP.Enforced }} - + {{ end }} {{ else }} - + {{ end }}
@@ -78,7 +78,7 @@ {{ end }} {{ else }} {{ end }}
diff --git a/auth/assets/templates/sessions.html.tpl b/auth/assets/templates/sessions.html.tpl index 461c0c3cb..36208d5e7 100644 --- a/auth/assets/templates/sessions.html.tpl +++ b/auth/assets/templates/sessions.html.tpl @@ -1,18 +1,18 @@ {{ template "inc_header.html.tpl" set . "activeNav" "sessions" }}
-
-

{{ tr "session.template.title" }}

- {{ if .sessions}} - - {{ end }} -
+
+

{{ tr "sessions.template.title" }}

+ {{ if .sessions}} + + {{ end }} +
{{ if .Current }} -
{{ tr "session.template.form.title" }}
+
{{ tr "sessions.template.list.current" }}
{{ end }} {{ if not .Current }} {{ end }} - +

- +

{{ .RemoteAddr }}

{{ if .SameRemoteAddr}} - {{ tr "session.template.form.span-machine" }} + {{ tr "sessions.template.list.same-machine" }} {{ end }} - +

{{ if .Expired }} - {{ tr "session.template.form.label-expire.expired" }} + {{ tr "sessions.template.list.expired" }} {{ else if eq .ExpiresIn 0 }} - {{ tr "session.template.form.label-expire.today" }} + {{ tr "sessions.template.list.today" }} {{ else if eq .ExpiresIn 1 }} - {{ tr "session.template.form.label-expire.when" }} + {{ tr "sessions.template.list.tomorrow" }} {{ else }} - in {{ .ExpiresIn }} days + {{ tr "sessions.template.list.soon" "days" .ExpiresIn }} {{ end }} - +

{{ .UserAgent }}

{{ if .SameUserAgent}} - {{ tr "session.template.form.span-browser" }} + {{ tr "sessions.template.list.same-browser" }} {{ end }}
{{ end }} diff --git a/auth/assets/templates/signup.html.tpl b/auth/assets/templates/signup.html.tpl index e97b4573d..7dc2a7858 100644 --- a/auth/assets/templates/signup.html.tpl +++ b/auth/assets/templates/signup.html.tpl @@ -25,7 +25,7 @@ placeholder="{{ tr "signup.template.form.email.placeholder" }}" autocomplete="username" value="{{ .form.email }}" - aria-label="{{ tr "signup.template.form.email.aria-label" }}"> + aria-label="{{ tr "signup.template.form.email.label" }}">
+<<<<<<< HEAD
{{ tr "signup.template.form.link.alternative" }} {{ tr "signup.template.form.link.login" }} +======= +
+ {{ tr "signup.template.log-in" "link" links.Login }} +>>>>>>> 838e629a... Translation fixes
+ {{ template "inc_footer.html.tpl" . }} diff --git a/auth/handlers/handle_authorized-clients.go b/auth/handlers/handle_authorized-clients.go index a31f77f2c..8cd353d89 100644 --- a/auth/handlers/handle_authorized-clients.go +++ b/auth/handlers/handle_authorized-clients.go @@ -63,7 +63,7 @@ func (h *AuthHandlers) clientsProc(req *request.AuthReq) error { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "primary", - Text: t("authorized-clients.alerts.text"), + Text: t("authorized-clients.alerts.removed"), }) } diff --git a/auth/handlers/handle_logout.go b/auth/handlers/handle_logout.go index 0a39c1063..0a062bf2e 100644 --- a/auth/handlers/handle_logout.go +++ b/auth/handlers/handle_logout.go @@ -21,6 +21,12 @@ func (h *AuthHandlers) logoutProc(req *request.AuthReq) (err error) { h.Log.Info("logout successful") req.Template = TmplLogout - req.Data["backlink"] = req.Request.FormValue("back") + + if req.Request.FormValue("back") != "" { + req.Data["link"] = req.Request.FormValue("back") + } else { + req.Data["link"] = GetLinks().Login + } + return } diff --git a/auth/handlers/handle_mfa.go b/auth/handlers/handle_mfa.go index 2536a8449..ab4f3acfe 100644 --- a/auth/handlers/handle_mfa.go +++ b/auth/handlers/handle_mfa.go @@ -59,7 +59,7 @@ func (h AuthHandlers) mfaProc(req *request.AuthReq) (err error) { t := translator(req, "auth") - req.PushAlert(t("mfa.handle.email-resent")) + req.PushAlert(t("mfa.email.resent")) req.AuthUser.CompleteEmailOTP() case "verifyTotp": @@ -75,7 +75,7 @@ func (h AuthHandlers) mfaProc(req *request.AuthReq) (err error) { t := translator(req, "auth") - req.PushAlert(t("mfa.handle.topt-valid")) + req.PushAlert(t("mfa.topt.valid")) req.AuthUser.CompleteTOTP() } diff --git a/auth/handlers/handle_oauth2.go b/auth/handlers/handle_oauth2.go index 2c2c90355..3fecb8a6b 100644 --- a/auth/handlers/handle_oauth2.go +++ b/auth/handlers/handle_oauth2.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "html/template" "net/http" "net/url" "strconv" @@ -95,17 +94,13 @@ func (h AuthHandlers) oauth2AuthorizeClient(req *request.AuthReq) (err error) { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "danger", - Text: fmt.Sprintf(t("oauth2_authorize_client.alerts.no-auth-or-prems"), req.Client), + Text: t("oauth2-authorize-client.alerts.denied", "client", req.Client.Meta.Name), }) return nil } if !req.AuthUser.User.EmailConfirmed { - req.Data["invalidUser"] = template.HTML(fmt.Sprintf( - `Cannot continue with unauthorized email, visit your profile and resolve the issue.`, - GetLinks().Profile, - )) - + req.Data["invalidUser"] = true req.Data["disabled"] = true } else if client.Trusted { h.Log.Debug("pre-authorized trusted oauth2 client") @@ -145,7 +140,7 @@ func (h AuthHandlers) oauth2AuthorizeClientProc(req *request.AuthReq) (err error t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "warning", - Text: t("oauth2_authorize_client.alerts.client-access-denied"), + Text: t("oauth2-authorize-client.alerts.denied", "client", req.Client.Meta.Name), }) return } diff --git a/auth/handlers/handle_security.go b/auth/handlers/handle_security.go index ae6752620..fc0c58c7b 100644 --- a/auth/handlers/handle_security.go +++ b/auth/handlers/handle_security.go @@ -38,7 +38,7 @@ func (h *AuthHandlers) securityProc(req *request.AuthReq) error { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "primary", - Text: t("security.TFA-TOTP-disabled"), + Text: t("security.totp-disabled"), }) // Make sure we update User's data in the session diff --git a/auth/handlers/handler.go b/auth/handlers/handler.go index 98b717915..af4b1ab09 100644 --- a/auth/handlers/handler.go +++ b/auth/handlers/handler.go @@ -22,6 +22,7 @@ import ( "github.com/gorilla/csrf" "github.com/gorilla/sessions" "github.com/markbates/goth" + "github.com/spf13/cast" "go.uber.org/zap" ) @@ -233,8 +234,13 @@ func (h *AuthHandlers) handle(fn handlerFn) http.HandlerFunc { // translator template function ttf = func(t *template.Template) *template.Template { return t.Funcs(map[string]interface{}{ - "tr": func(key string, pp ...string) string { - return loc.Get(req.Context(), "auth", key, pp...) + "tr": func(key string, pp ...interface{}) template.HTML { + ss := make([]string, len(pp)) + for i := range pp { + ss[i] = cast.ToString(pp[i]) + } + + return template.HTML(loc.Get(req.Context(), "auth", key, ss...)) }, }) } diff --git a/pkg/locale/json.go b/pkg/locale/json.go deleted file mode 100644 index 73ffe6ed0..000000000 --- a/pkg/locale/json.go +++ /dev/null @@ -1 +0,0 @@ -package locale diff --git a/pkg/locale/load.go b/pkg/locale/load.go index e478bece6..a5be84298 100644 --- a/pkg/locale/load.go +++ b/pkg/locale/load.go @@ -183,9 +183,20 @@ func loadTranslations(lang *Language, dir string) (err error) { return } + // wraps JSON with namespaces under each app with a language tag: + // { : { namespace ..., namespace ... } } + // + // This simplifies and unifies the output and makes it compatible + // with the frontend libs for app, nss := range auxExternal { - var buf = &bytes.Buffer{} - if err = json.NewEncoder(buf).Encode(nss); err != nil { + var ( + buf = &bytes.Buffer{} + aux = make(map[string]interface{}) + ) + + aux[lang.Tag.String()] = nss + + if err = json.NewEncoder(buf).Encode(aux); err != nil { return } lang.external[app] = buf