diff --git a/front.go b/front.go index 0ee8d91..a7b920b 100644 --- a/front.go +++ b/front.go @@ -180,6 +180,7 @@ func RenderHTML(templateString string, args ...interface{}) (template.HTML, erro type baseContext struct { T func(string, ...interface{}) string + TN func(string, string, int, ...interface{}) string App *App L *gotext.Locale URL string @@ -191,10 +192,12 @@ type baseContext struct { func (app *App) NewBaseContext(c *echo.Context) baseContext { l := (*c).Get(CONTEXT_KEY_LOCALE).(*gotext.Locale) T := l.Get + TN := l.GetN return baseContext{ App: app, L: l, T: T, + TN: TN, URL: (*c).Request().URL.RequestURI(), SuccessMessage: app.lastSuccessMessage(c), WarningMessage: app.lastWarningMessage(c), diff --git a/view/admin.tmpl b/view/admin.tmpl index 924def8..262de42 100644 --- a/view/admin.tmpl +++ b/view/admin.tmpl @@ -36,7 +36,7 @@ >
Player | -UUID | +{{ call .T "Player" }} | +{{ call .T "UUID" }} | {{ if or .App.Config.AllowAddingDeletingPlayers .User.IsAdmin }} -Delete Player | +{{ call .T "Delete Player" }} | {{ end }}- {{ $player.Name }} + {{ $player.Name }} | {{ $player.UUID }} | {{ if or $.App.Config.AllowAddingDeletingPlayers $.User.IsAdmin }}- + | {{ end }} @@ -79,32 +85,55 @@
- {{ if or (and (not .User.IsAdmin) (not .App.Config.AllowAddingDeletingPlayers)) (eq .MaxPlayerCount 0) }} - {{ if .AdminView }}{{ .TargetUser.Username }} is{{ else }}You are{{ end }} not allowed to create new players. - {{ if .AdminView }}You can override this limit since you're an admin.{{ end }} +
{{ if or (and (not .User.IsAdmin) (not .App.Config.AllowAddingDeletingPlayers)) (eq .MaxPlayerCount 0) }} + {{ if .AdminView }} + {{ call .T + "%s is not allowed to add new players. You can override this limit since you're an admin." + .TargetUser.Username + }} + {{ else }} + {{ call .T "You are not allowed to add new players." }} + {{ end }} {{ else if (gt .MaxPlayerCount 0) }} - {{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}Your{{ end }} account can have up to {{ .MaxPlayerCount }} player(s). - {{ if .AdminView }}You can override this limit since you're an admin.{{ end }} + {{ if .AdminView }} + {{ call .TN + "%s is only allowed to have %d player. You can override this limit since you're an admin." + "%s is allowed to have up to %d players. You can override this limit since you're an admin." + .MaxPlayerCount + .TargetUser.Username + .MaxPlayerCount + }} + {{ else }} + {{ call .TN + "You are only allowed to have %d player." + "You are allowed to have up to %d players." + .MaxPlayerCount + .TargetUser.Username + .MaxPlayerCount + }} + {{ end }} {{ else }} - {{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}Your{{ end }} account can have an unlimited number of players. - {{ end }} -
+ {{ if .AdminView }} + {{ call .T "%s is allowed to have an unlimited number of players." }} + {{ else }} + {{ call .T "You are allowed to have an unlimited number of players." }} + {{ end }} + {{ end }} {{ if or (and .App.Config.AllowAddingDeletingPlayers (or (lt (len .TargetUser.Players) .MaxPlayerCount) (lt .MaxPlayerCount 0))) .User.IsAdmin }} {{ if .App.Config.CreateNewPlayer.Allow }} {{ if or .User.IsAdmin .App.Config.CreateNewPlayer.AllowChoosingUUID }} -Create a new player with a random UUID:
+{{ call .T "Create a new player with a random UUID:" }}
{{ end }} {{ end }} {{ if .App.Config.ImportExistingPlayer.Allow }} -- Create a new player with the UUID of an existing - {{ .App.Config.ImportExistingPlayer.Nickname }} player. - Requires verification that you own the account. -
+{{ call .T + "Create a new player with the UUID of an existing %s player. Requires verification that you own the account." + .App.Config.ImportExistingPlayer.Nickname + }}
{{ else }} -- Create a new player with the UUID of an existing - {{ .App.Config.ImportExistingPlayer.Nickname }} player. -
+{{ call .T + "Create a new player with the UUID of an existing %s player." + .App.Config.ImportExistingPlayer.Nickname + }}
{{ end }} {{ end }} {{ end }} {{ if gt (len .App.OIDCProvidersByName) 0 }} -- These external accounts are linked to {{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}your{{ end }} {{ .App.Config.ApplicationName }} account: -
+{{ if .AdminView }} {{ call .T + "These external accounts are linked to %s's %s account:" + .TargetUser.Username + .App.Config.ApplicationName + }}{{ else }}{{ call .T + "These external accounts are linked to your %s account:" + .App.Config.ApplicationName + }}{{ end }}
- No external accounts are linked to {{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}your{{ end }} {{ .App.Config.ApplicationName }} account.
+ -{{ if .AdminView }}{{ call .T + "No external accounts are linked to %s's account." + .TargetUser.Username + }}{{ else }}{{ call .T + "No external accounts are linked to your account." + }}
{{ end }} {{ if and (eq .User.UUID .TargetUser.UUID) (gt (len $.UnlinkedOIDCProviders) 0) }} {{ range $provider := $.UnlinkedOIDCProviders }} {{ end }}
Delete Account
+ {{ call .T "Delete Account" }}