mirror of
https://github.com/unmojang/drasl.git
synced 2025-08-03 10:56:06 -04:00
i18n root, footer
This commit is contained in:
parent
439e1ae369
commit
5e3d8e1929
40
front.go
40
front.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
@ -16,6 +17,7 @@ import (
|
||||
"github.com/zitadel/oidc/v3/pkg/oidc"
|
||||
"golang.org/x/text/language"
|
||||
"gorm.io/gorm"
|
||||
"html"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
@ -66,6 +68,8 @@ func NewTemplate(app *App) *Template {
|
||||
}
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
"render": RenderHTML,
|
||||
"html": func(x string) template.HTML { return template.HTML(x) },
|
||||
"PrimaryPlayerSkinURL": app.PrimaryPlayerSkinURL,
|
||||
"PlayerSkinURL": app.PlayerSkinURL,
|
||||
"InviteURL": app.InviteURL,
|
||||
@ -156,7 +160,23 @@ func NewWebError(returnURL string, message string, args ...interface{}) error {
|
||||
}
|
||||
}
|
||||
|
||||
func RenderHTML(templateString string, args ...interface{}) (template.HTML, error) {
|
||||
t, err := template.New("").Parse(templateString)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
err = t.Execute(&buf, args)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return template.HTML(buf.String()), nil
|
||||
}
|
||||
|
||||
type baseContext struct {
|
||||
T func(string, ...interface{}) template.HTML
|
||||
App *App
|
||||
L *gotext.Locale
|
||||
URL string
|
||||
@ -165,10 +185,28 @@ type baseContext struct {
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
func NewT(l *gotext.Locale) func(string, ...interface{}) template.HTML {
|
||||
return func(msgid string, args ...interface{}) template.HTML {
|
||||
sanitized := make([]interface{}, 0, len(args))
|
||||
for _, arg := range args {
|
||||
switch arg.(type) {
|
||||
case template.HTML:
|
||||
sanitized = append(sanitized, arg)
|
||||
default:
|
||||
sanitized = append(sanitized, html.EscapeString(fmt.Sprint(arg)))
|
||||
}
|
||||
}
|
||||
return template.HTML(l.Get(msgid, sanitized...))
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) NewBaseContext(c *echo.Context) baseContext {
|
||||
l := (*c).Get(CONTEXT_KEY_LOCALE).(*gotext.Locale)
|
||||
T := NewT((*c).Get(CONTEXT_KEY_LOCALE).(*gotext.Locale))
|
||||
return baseContext{
|
||||
App: app,
|
||||
L: (*c).Get(CONTEXT_KEY_LOCALE).(*gotext.Locale),
|
||||
L: l,
|
||||
T: T,
|
||||
URL: (*c).Request().URL.RequestURI(),
|
||||
SuccessMessage: app.lastSuccessMessage(c),
|
||||
WarningMessage: app.lastWarningMessage(c),
|
||||
|
@ -14,3 +14,99 @@ msgstr "Cuenta de %s"
|
||||
|
||||
msgid "Log out"
|
||||
msgstr "Cerrar sesión"
|
||||
|
||||
msgid "Log in"
|
||||
msgstr "Iniciar sesión"
|
||||
|
||||
msgid "Sign in with %s"
|
||||
msgstr "Iniciar sesión con %s"
|
||||
|
||||
msgid "or"
|
||||
msgstr "o"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "Nombre de usuario"
|
||||
|
||||
msgid "Password"
|
||||
msgstr "Contraseña"
|
||||
|
||||
msgid "Configuring your client"
|
||||
msgstr "Configurando tu cliente"
|
||||
|
||||
msgid "Using %s on the client requires a third-party launcher that supports custom API servers. %s, a fork of Prism Launcher, is recommended, but %s also works. Both are free/libre."
|
||||
msgstr "Usar %s en el cliente requiere un lanzador de terceros que soporte servidores API personalizados. Se recomienda %s, un fork de Prism Launcher, pero %s también funciona. Ambos son libres."
|
||||
|
||||
msgid "Click your account in the top right and select “Manage Accounts...”."
|
||||
msgstr "Haz clic en tu cuenta en la esquina superior derecha y selecciona “Administrar cuentas...”."
|
||||
|
||||
msgid "Click “Add authlib-injector” in the right-hand sidebar."
|
||||
msgstr "Haz clic en “Add authlib-injector” en la barra lateral derecha."
|
||||
|
||||
msgid "Enter your player name and your %s password or Minecraft Token, and use %s for the URL. Click “OK”."
|
||||
msgstr "Introduce tu nombre de jugador y tu contraseña de %s o Token de Minecraft, y usa %s para la URL. Haz clic en “Aceptar”."
|
||||
|
||||
msgid "Go to the “Account List” view by clicking the account at the top of the sidebar."
|
||||
msgstr "Ve a la vista “Lista de cuentas” haciendo clic en la cuenta en la parte superior de la barra lateral."
|
||||
|
||||
msgid "At the bottom left, click “New Auth Server” and enter %s. Click “Next” and then “Finish”."
|
||||
msgstr "En la parte inferior izquierda, haz clic en “Añadir un servidor de autenticación” e ingresa %s. Haz clic en “Siguiente” y luego en “Finalizar”."
|
||||
|
||||
msgid "In the sidebar, click the newly-added authentication server, labeled “%s”. Enter your %s player name and password and click “Login”."
|
||||
msgstr "En la barra lateral, haz clic en el servidor de autenticación recién añadido, etiquetado como “%s”. Ingresa tu nombre de jugador y contraseña de %s y haz clic en “Acceder”."
|
||||
|
||||
msgid "Other launchers"
|
||||
msgstr "Otros lanzadores"
|
||||
|
||||
msgid "Use the authlib-injector URL %s."
|
||||
msgstr "Usa la URL de authlib-injector %s."
|
||||
|
||||
msgid "Or, if your launcher supports custom API servers but not via authlib-injector, use the following URLs:"
|
||||
msgstr "O, si tu lanzador soporta servidores API personalizados pero no a través de authlib-injector, usa las siguientes URLs:"
|
||||
|
||||
msgid "Authentication server:"
|
||||
msgstr "Servidor de “Authentication”:"
|
||||
|
||||
msgid "Account server:"
|
||||
msgstr "Servidor de “Account”:"
|
||||
|
||||
msgid "Session server:"
|
||||
msgstr "Servidor de “Session”:"
|
||||
|
||||
msgid "Services server:"
|
||||
msgstr "Servidor de “Services”:"
|
||||
|
||||
msgid "Configuring your server"
|
||||
msgstr "Configurando tu servidor"
|
||||
|
||||
msgid "Minecraft 1.16 and later"
|
||||
msgstr "Minecraft 1.16 y posteriores"
|
||||
|
||||
msgid "On recent versions of Minecraft, you can use %s on an unmodified Vanilla server. To do so, add the following arguments before you specify the jar file when you start the server:"
|
||||
msgstr "En las versiones recientes de Minecraft, puedes usar %s en un servidor Vanilla sin modificaciones. Para hacerlo, agrega los siguientes argumentos antes de especificar el archivo jar al iniciar el servidor:"
|
||||
|
||||
msgid "For example, the full command you use to start the server might be:"
|
||||
msgstr "Por ejemplo, el comando completo que usas para iniciar el servidor podría ser:"
|
||||
|
||||
msgid "Minecraft 1.7.2 through 1.15.2"
|
||||
msgstr "Minecraft 1.7.2 a 1.15.2"
|
||||
|
||||
msgid "Refer to <a href=\"%s\">the authlib-injector documentation on setting up a server</a>."
|
||||
msgstr "Consulta <a href=\"%s\">la documentación de authlib-injector sobre cómo configurar un servidor</a>."
|
||||
|
||||
msgid "Alternatively, you can patch your server to use a newer version of Mojang's authlib that supports the arguments for custom API servers. Replace the files under <code>com/mojang/authlib</code> in your <code>server.jar</code> with the files in <a href=\"%s\">authlib-1.6.25.jar</a>."
|
||||
msgstr "Alternativamente, puedes parchear tu servidor para usar una versión más reciente de authlib de Mojang que soporte los argumentos para servidores API personalizados. Reemplaza los archivos bajo <code>com/mojang/authlib</code> en tu <code>server.jar</code> con los archivos en <a href=\"%s\">authlib-1.6.25.jar</a>."
|
||||
|
||||
msgid "<a href=\"%s\">Late Classic</a>, Alpha, Beta, etc. through Minecraft 1.6.4"
|
||||
msgstr "<a href=\"%s\">Clásico Tardío</a>, Alpha, Beta, etc. hasta Minecraft 1.6.4"
|
||||
|
||||
msgid "Use %s and start the server with the <code>-Dminecraft.api.session.host</code> argument described above. For example, the full command you use to start the server might be:"
|
||||
msgstr "Usa %s y arranca el servidor con el argumento <code>-Dminecraft.api.session.host</code> descrito arriba. Por ejemplo, el comando completo que usas para iniciar el servidor podría ser:"
|
||||
|
||||
msgid "Drasl version %s."
|
||||
msgstr "Versión de Drasl %s."
|
||||
|
||||
msgid "Licensed as %s."
|
||||
msgstr "Con licencia %s."
|
||||
|
||||
msgid "<a href=\"%s\">Source code</a>."
|
||||
msgstr "<a href=\"%s\">Código fuente</a>."
|
||||
|
@ -2,9 +2,9 @@
|
||||
{{ if .App.Config.EnableFooter }}
|
||||
<hr />
|
||||
<small>
|
||||
Drasl version {{ .App.Constants.Version }}. Licensed under
|
||||
<a href="{{ .App.Constants.LicenseURL }}">{{ .App.Constants.License }}</a>.
|
||||
Source code <a href="{{ .App.Constants.RepositoryURL }}">here</a>.
|
||||
{{ call .T `Drasl version %s.` .App.Constants.Version }}
|
||||
{{ call .T `Licensed as %s.` (render `<a href="{{ index . 0 }}">{{ index . 1 }}</a>` .App.Constants.LicenseURL .App.Constants.License) }}
|
||||
{{ call .T `<a href="%s">Source code</a>.` .App.Constants.RepositoryURL }}
|
||||
</small>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
@ -11,20 +11,20 @@
|
||||
<div style="text-align: right">
|
||||
{{ if .User }}
|
||||
{{ if .User.IsAdmin }}
|
||||
<a href="{{ .App.FrontEndURL }}/web/admin">{{ .L.Get "Admin" }}</a>
|
||||
<a href="{{ .App.FrontEndURL }}/web/admin">{{ call .T "Admin" }}</a>
|
||||
{{ end }}
|
||||
<a href="{{ .App.FrontEndURL }}/web/user"
|
||||
>{{ .L.Get "%s's Account" .User.Username }}</a
|
||||
>{{ call .T "%s's Account" .User.Username }}</a
|
||||
>
|
||||
<form
|
||||
style="display: inline"
|
||||
action="{{ .App.FrontEndURL }}/web/logout"
|
||||
method="post"
|
||||
>
|
||||
<input type="submit" value="{{ .L.Get "Log out" }}" />
|
||||
<input type="submit" value="{{ call .T "Log out" }}" />
|
||||
</form>
|
||||
{{ else }}
|
||||
<a href="{{ .App.FrontEndURL }}/web/registration">{{ .L.Get "Register" }}</a>
|
||||
<a href="{{ .App.FrontEndURL }}/web/registration">{{ call .T "Register" }}</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{ define "base" }}
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="{{ .L.GetLanguage }}">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
121
view/root.tmpl
121
view/root.tmpl
@ -4,7 +4,10 @@
|
||||
|
||||
{{ define "content" }}
|
||||
{{ template "header" . }}
|
||||
<h3>Log in</h3>
|
||||
|
||||
{{ $authlibInjectorA := render `<a href="{{ index . 0}}">{{ index . 1}}</a>` .App.AuthlibInjectorURL .App.AuthlibInjectorURL }}
|
||||
|
||||
<h3>{{ call .T "Log in" }}</h3>
|
||||
|
||||
{{ $dividerNeeded := false }}
|
||||
|
||||
@ -16,7 +19,7 @@
|
||||
<h3><img class="openid-logo" src="{{ .App.PublicURL }}/openid-logo.svg" alt="OpenID logo"></h3>
|
||||
{{ range $provider := $.WebOIDCProviders }}
|
||||
<p>
|
||||
<a href="{{ $provider.AuthURL }}">Sign in with {{ $provider.Name }}</a>
|
||||
<a href="{{ $provider.AuthURL }}">{{ call $.T "Sign in with %s" $provider.Name }}</a>
|
||||
</p>
|
||||
{{ end }}
|
||||
{{ $dividerNeeded = true }}
|
||||
@ -24,106 +27,94 @@
|
||||
|
||||
{{ if .App.Config.AllowPasswordLogin }}
|
||||
{{ if $dividerNeeded }}
|
||||
<div class="divider">or</div>
|
||||
<div class="divider">{{ call .T "or" }}</div>
|
||||
{{ $dividerNeeded = false }}
|
||||
{{ end }}
|
||||
<form action="{{ .App.FrontEndURL }}/web/login" method="post">
|
||||
<input type="text" name="username" placeholder="Username" required />
|
||||
<input type="text" name="username" placeholder="{{ call .T "Username" }}" required />
|
||||
<input hidden name="returnUrl" value="{{ .URL }}" />
|
||||
<input hidden name="destination" value="{{ .Destination }}" />
|
||||
<input
|
||||
class="long"
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
placeholder="{{ call .T "Password" }}"
|
||||
required
|
||||
/>
|
||||
<input type="submit" value="Log in" />
|
||||
<input type="submit" value="{{ call .T "Log in" }}" />
|
||||
</form>
|
||||
{{ $dividerNeeded = true }}
|
||||
{{ end }}
|
||||
|
||||
<h3>Configuring your client</h3>
|
||||
<h3>{{ call .T "Configuring your client" }}</h3>
|
||||
<p>
|
||||
Using {{ .App.Config.ApplicationName }} on the client requires a third-party launcher that supports
|
||||
custom API servers.
|
||||
<a href="https://github.com/unmojang/FjordLauncher">Fjord Launcher</a>, a
|
||||
fork of Prism Launcher, is recommended, but
|
||||
<a href="https://github.com/huanghongxun/HMCL">HMCL</a> also works. Both are
|
||||
free/libre.
|
||||
{{ call .T "Using %s on the client requires a third-party launcher that supports custom API servers. %s, a fork of Prism Launcher, is recommended, but %s also works. Both are free/libre."
|
||||
.App.Config.ApplicationName
|
||||
(html `<a href="https://github.com/unmojang/FjordLauncher">Fjord Launcher</a>`)
|
||||
(html `<a href="https://github.com/huanghongxun/HMCL">HMCL</a>`) }}
|
||||
</p>
|
||||
|
||||
<h4>Fjord Launcher</h4>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
Click your account in the top right and select "Manage Accounts...".
|
||||
</li>
|
||||
<li>Click "Add authlib-injector" in the right-hand sidebar.</li>
|
||||
<li>
|
||||
Enter your player name and your {{ .App.Config.ApplicationName }} password or Minecraft Token, and use
|
||||
<a href="{{ .App.AuthlibInjectorURL }}">{{ .App.AuthlibInjectorURL }}</a>
|
||||
for the URL. Click "OK".
|
||||
</li>
|
||||
<li>{{ call .T "Click your account in the top right and select “Manage Accounts...”." }} </li>
|
||||
<li>{{ call .T "Click “Add authlib-injector” in the right-hand sidebar." }}</li>
|
||||
<li>{{ call .T
|
||||
"Enter your player name and your %s password or Minecraft Token, and use %s for the URL. Click “OK”."
|
||||
.App.Config.ApplicationName
|
||||
$authlibInjectorA
|
||||
}}</li>
|
||||
</ol>
|
||||
|
||||
<h4>HMCL</h4>
|
||||
|
||||
<ol>
|
||||
<li>{{ call .T "Go to the “Account List” view by clicking the account at the top of the sidebar." }}</li>
|
||||
<li>
|
||||
Go to the "Account List" view by clicking the account at the top of the
|
||||
sidebar.
|
||||
{{ call .T
|
||||
"At the bottom left, click “New Auth Server” and enter %s. Click “Next” and then “Finish”."
|
||||
$authlibInjectorA
|
||||
}}
|
||||
</li>
|
||||
<li>
|
||||
At the bottom left, click "New Auth Server" and enter
|
||||
<a href="{{ .App.AuthlibInjectorURL }}">{{ .App.AuthlibInjectorURL }}</a>.
|
||||
Click "Next" and then "Finish".
|
||||
</li>
|
||||
<li>
|
||||
In the sidebar, click the newly-added authentication server, labeled
|
||||
"{{ .App.Config.InstanceName }}". Enter your {{ .App.Config.ApplicationName }} player name and password
|
||||
and click "Login".
|
||||
{{ call .T
|
||||
"In the sidebar, click the newly-added authentication server, labeled “%s”. Enter your %s player name and password and click “Login”."
|
||||
.App.Config.InstanceName
|
||||
.App.Config.ApplicationName
|
||||
}}
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h4>Other Launchers</h4>
|
||||
<h4>{{ call .T "Other launchers" }}</h4>
|
||||
|
||||
<p>
|
||||
Use the authlib-injector URL
|
||||
<a href="{{ .App.AuthlibInjectorURL }}">{{ .App.AuthlibInjectorURL }}</a>.
|
||||
</p>
|
||||
<p>{{ call .T "Use the authlib-injector URL %s." $authlibInjectorA }}</p>
|
||||
|
||||
<p>
|
||||
Or, if your launcher supports custom API servers but not via
|
||||
authlib-injector, use the following URLs:
|
||||
</p>
|
||||
<p>{{ call .T "Or, if your launcher supports custom API servers but not via authlib-injector, use the following URLs:" }}</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Authentication Server:</td>
|
||||
<td>{{ call .T "Authentication server:" }}</td>
|
||||
<td>{{ .App.AuthURL }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Account Server:</td>
|
||||
<td>{{ call .T "Account server:" }}</td>
|
||||
<td>{{ .App.AccountURL }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Session Server:</td>
|
||||
<td>{{ call .T "Session server:" }}</td>
|
||||
<td>{{ .App.SessionURL }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Services Server:</td>
|
||||
<td>{{ call .T "Services server:" }}</td>
|
||||
<td>{{ .App.ServicesURL }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Configuring your server</h3>
|
||||
<h3>{{ call .T "Configuring your server" }}</h3>
|
||||
|
||||
<h4>Minecraft 1.16 and later</h4>
|
||||
<h4>{{ call .T "Minecraft 1.16 and later" }}</h4>
|
||||
|
||||
On recent versions of Minecraft, you can use {{ .App.Config.ApplicationName }} on an unmodified Vanilla
|
||||
server. To do so, add the following arguments before you specify the jar file
|
||||
when you start the server:
|
||||
<p>{{ call .T "On recent versions of Minecraft, you can use %s on an unmodified Vanilla server. To do so, add the following arguments before you specify the jar file when you start the server:" }}</p>
|
||||
<pre style="word-wrap: break-word; white-space: pre-wrap; overflow-x: auto">
|
||||
-Dminecraft.api.env=custom
|
||||
-Dminecraft.api.auth.host={{ .App.AuthURL }}
|
||||
@ -131,7 +122,7 @@
|
||||
-Dminecraft.api.session.host={{ .App.SessionURL }}
|
||||
-Dminecraft.api.services.host={{ .App.ServicesURL }}</pre>
|
||||
|
||||
For example, the full command you use to start the server might be:
|
||||
<p>{{call .T "For example, the full command you use to start the server might be:" }}</p>
|
||||
<pre style="word-wrap: break-word; white-space: pre-wrap; overflow-x: auto">
|
||||
java -Xmx1024M -Xms1024M \
|
||||
-Dminecraft.api.env=custom \
|
||||
@ -141,24 +132,24 @@ java -Xmx1024M -Xms1024M \
|
||||
-Dminecraft.api.services.host={{ .App.ServicesURL }} \
|
||||
-jar server.jar nogui</pre>
|
||||
|
||||
<h4>Minecraft 1.7.2 through 1.15.2</h4>
|
||||
<h4>{{ call .T "Minecraft 1.7.2 through 1.15.2" }}</h4>
|
||||
|
||||
<p>
|
||||
Refer to the authlib-injector documentation on setting up a server:
|
||||
<a
|
||||
href="https://github.com/yushijinhun/authlib-injector/blob/develop/README.en.md#deploy"
|
||||
>https://github.com/yushijinhun/authlib-injector/blob/develop/README.en.md#deploy</a
|
||||
>.
|
||||
</p>
|
||||
<p>{{ call .T
|
||||
`Refer to <a href="%s">the authlib-injector documentation on setting up a server</a>.`
|
||||
"https://github.com/yushijinhun/authlib-injector/blob/develop/README.en.md#deploy"
|
||||
}}</p>
|
||||
|
||||
<p>
|
||||
Alternatively, you can patch your server to use a newer version of Mojang's authlib that supports the arguments for custom API servers. Replace the files under <code>com/mojang/authlib</code> in your <code>server.jar</code> with the files in <a href="https://libraries.minecraft.net/com/mojang/authlib/1.6.25/authlib-1.6.25.jar">authlib-1.6.25.jar</a>.
|
||||
</p>
|
||||
<p>{{ call .T
|
||||
`Alternatively, you can patch your server to use a newer version of Mojang's authlib that supports the arguments for custom API servers. Replace the files under <code>com/mojang/authlib</code> in your <code>server.jar</code> with the files in <a href="%s">authlib-1.6.25.jar</a>.`
|
||||
"https://libraries.minecraft.net/com/mojang/authlib/1.6.25/authlib-1.6.25.jar"
|
||||
}}</p>
|
||||
|
||||
<h4><a href="https://minecraft.wiki/w/Java_Edition_Late_Classic">Late Classic</a>, Alpha, Beta, etc. through Minecraft 1.6.4</h4>
|
||||
<h4>{{ call .T `<a href="%s">Late Classic</a>, Alpha, Beta, etc. through Minecraft 1.6.4` "https://minecraft.wiki/w/Java_Edition_Late_Classic" }}</h4>
|
||||
|
||||
<p>
|
||||
Use <a href="https://github.com/craftycodie/OnlineModeFix">OnlineModeFix</a> and start the server with the <code>-Dminecraft.api.session.host</code> argument described above. For example, the full command you use to start the server might be:
|
||||
<p>{{ call .T
|
||||
`Use %s and start the server with the <code>-Dminecraft.api.session.host</code> argument described above. For example, the full command you use to start the server might be:`
|
||||
(html `<a href="https://github.com/craftycodie/OnlineModeFix">OnlineModeFix</a>`)
|
||||
}}
|
||||
|
||||
<pre style="word-wrap: break-word; white-space: pre-wrap; overflow-x: auto">
|
||||
java -Xmx1024M -Xms1024M \
|
||||
|
Loading…
x
Reference in New Issue
Block a user