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 @@ > - {{ $invite.CreatedAt.Format "Jan _2 15:04:05 MST 2006" }} + {{ $invite.CreatedAt.Format (call $.T "Jan _2 15:04:05 MST 2006") }}
@@ -28,7 +28,12 @@ id="unlink-{{ $providerName }}" action="{{ $.App.FrontEndURL }}/web/oidc-unlink" method="post" - onsubmit="return confirm('Are you sure you want to unlink your {{ $providerName }} account? You will no longer be able to log in to your {{ $.App.Config.ApplicationName }} account using {{ $providerName }}.');" + onsubmit="return confirm('{{ + call $.T "Are you sure you want to unlink your %s account? You will no longer be able to log in to your %s account using %s." + $providerName + $.App.Config.ApplicationName + $providerName + }}');" > @@ -37,15 +42,19 @@ {{ end }} -

{{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}Your{{ end }} players

+

{{ if .AdminView }}{{ call .T + "%s's players" .TargetUser.Username + }}{{ else }}{{ call .T + "Your players" + }}{{ end }}

{{ if .TargetUser.Players }} - - + + {{ if or .App.Config.AllowAddingDeletingPlayers .User.IsAdmin }} - + {{ end }} @@ -63,15 +72,12 @@ > {{ if or $.App.Config.AllowAddingDeletingPlayers $.User.IsAdmin }} {{ end }} @@ -79,32 +85,55 @@
PlayerUUID{{ call .T "Player" }}{{ call .T "UUID" }}Delete Player{{ call .T "Delete Player" }}
- {{ $player.Name }} + {{ $player.Name }} {{ $player.UUID }} - +
{{ else }} - No players yet. + {{ call .T "No players yet." }} {{ end }} -

- {{ 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

+

{{ call .T "Create a new player" }}

{{ else }} -

Create a new player with a random UUID:

+

{{ call .T "Create a new player with a random UUID:" }}

{{ end }} @@ -113,62 +142,66 @@ class="long" type="text" name="playerUuid" - placeholder="Player UUID (leave blank for random)" + placeholder="{{ call .T "Player UUID (leave blank for random)" }}" pattern="^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$" /> {{ end }} - +
{{ end }} {{ if .App.Config.ImportExistingPlayer.Allow }} -

Import a(n) {{ .App.Config.ImportExistingPlayer.Nickname }} player

+

{{ call .T "Import a player from %s" .App.Config.ImportExistingPlayer.Nickname }}

{{ if .App.Config.ImportExistingPlayer.RequireSkinVerification }} -

- 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 }} -

Linked accounts

+

{{ call .T "Linked accounts" }}

{{ if gt (len $.LinkedOIDCProviderNames) 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 }}

{{ range $providerName := $.LinkedOIDCProviderNames }} @@ -178,8 +211,8 @@ @@ -187,20 +220,26 @@
{{ else }} -

- No external accounts are linked to {{ if .AdminView }}{{ .TargetUser.Username }}'s{{ else }}your{{ end }} {{ .App.Config.ApplicationName }} account. If you link an external account, you will no longer be able to log in using your {{ .App.Config.ApplicationName }} password. You'll need to use your Minecraft Token to log in to Minecraft launchers. -

+

{{ 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." + }} {{ call .T + "If you link an external account, you will no longer be able to log in using your %s password. You'll need to use your Minecraft Token to log into Minecraft Launchers" + .App.Config.ApplicationName + }}{{ end }}

{{ end }} {{ if and (eq .User.UUID .TargetUser.UUID) (gt (len $.UnlinkedOIDCProviders) 0) }} {{ range $provider := $.UnlinkedOIDCProviders }}

- Link with {{ $provider.Name }} + {{ call $.T "Link with %s" $provider.Name }}

{{ end }} {{ end }} {{ end }} -

Account settings

+

{{ call .T "Account settings" }}

{{ if and .User.IsAdmin (not .TargetUser.IsAdmin) }}

-
- Specify -1 to allow unlimited players or leave blank to reset to the configured default value.
+
+ {{ call .T "Specify -1 to allow unlimited players or leave blank to reset to the configured default value." }}
-
+

{{ end }}

-
- Can be used instead of a password to sign in to Minecraft launchers.
+
+ {{ call .T "Can be used instead of a password to sign in to Minecraft launchers." }}

- +

-
+
{{ if ne .App.Constants.SwaggerUIURL "" }} - See the {{ .App.Config.ApplicationName }} API documentation.
+ {{ render + (call .T `See the %s API documentation` .App.Config.ApplicationName) + (printf "%s/?url=%s/swagger.json" .App.Constants.SwaggerUIURL .App.APIURL) + }}
{{ end }}
- +

-
+

- +

- Delete Account + {{ call .T "Delete Account" }}
- +