diff --git a/front.go b/front.go
index 8ca4665..8ef69b1 100644
--- a/front.go
+++ b/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),
diff --git a/locales/es/default.po b/locales/es/default.po
index 4d3ffa4..0986540 100644
--- a/locales/es/default.po
+++ b/locales/es/default.po
@@ -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 the authlib-injector documentation on setting up a server."
+msgstr "Consulta la documentación de authlib-injector sobre cómo configurar un servidor."
+
+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 com/mojang/authlib
in your server.jar
with the files in authlib-1.6.25.jar."
+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 com/mojang/authlib
en tu server.jar
con los archivos en authlib-1.6.25.jar."
+
+msgid "Late Classic, Alpha, Beta, etc. through Minecraft 1.6.4"
+msgstr "Clásico Tardío, Alpha, Beta, etc. hasta Minecraft 1.6.4"
+
+msgid "Use %s and start the server with the -Dminecraft.api.session.host
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 -Dminecraft.api.session.host
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 "Source code."
+msgstr "Código fuente."
diff --git a/view/footer.tmpl b/view/footer.tmpl
index d702da5..be27c4c 100644
--- a/view/footer.tmpl
+++ b/view/footer.tmpl
@@ -2,9 +2,9 @@
{{ if .App.Config.EnableFooter }}
- Sign in with {{ $provider.Name }} + {{ call $.T "Sign in with %s" $provider.Name }}
{{ end }} {{ $dividerNeeded = true }} @@ -24,106 +27,94 @@ {{ if .App.Config.AllowPasswordLogin }} {{ if $dividerNeeded }} -- Using {{ .App.Config.ApplicationName }} on the client requires a third-party launcher that supports - custom API servers. - Fjord Launcher, a - fork of Prism Launcher, is recommended, but - HMCL 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 `Fjord Launcher`) + (html `HMCL`) }}
- Use the authlib-injector URL - {{ .App.AuthlibInjectorURL }}. -
+{{ call .T "Use the authlib-injector URL %s." $authlibInjectorA }}
-- Or, if your launcher supports custom API servers but not via - authlib-injector, use the following URLs: -
+{{ call .T "Or, if your launcher supports custom API servers but not via authlib-injector, use the following URLs:" }}
Authentication Server: | +{{ call .T "Authentication server:" }} | {{ .App.AuthURL }} |
Account Server: | +{{ call .T "Account server:" }} | {{ .App.AccountURL }} |
Session Server: | +{{ call .T "Session server:" }} | {{ .App.SessionURL }} |
Services Server: | +{{ call .T "Services server:" }} | {{ .App.ServicesURL }} |
{{ 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:" }}
-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 }}- For example, the full command you use to start the server might be: +
{{call .T "For example, the full command you use to start the server might be:" }}
java -Xmx1024M -Xms1024M \ -Dminecraft.api.env=custom \ @@ -141,24 +132,24 @@ java -Xmx1024M -Xms1024M \ -Dminecraft.api.services.host={{ .App.ServicesURL }} \ -jar server.jar nogui-
- Refer to the authlib-injector documentation on setting up a server: - https://github.com/yushijinhun/authlib-injector/blob/develop/README.en.md#deploy. -
+{{ call .T + `Refer to the authlib-injector documentation on setting up a server.` + "https://github.com/yushijinhun/authlib-injector/blob/develop/README.en.md#deploy" + }}
-
- 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 com/mojang/authlib
in your server.jar
with the files in authlib-1.6.25.jar.
-
{{ 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 com/mojang/authlib
in your server.jar
with the files in authlib-1.6.25.jar.`
+ "https://libraries.minecraft.net/com/mojang/authlib/1.6.25/authlib-1.6.25.jar"
+ }}
- Use OnlineModeFix and start the server with the -Dminecraft.api.session.host
argument described above. For example, the full command you use to start the server might be:
+
{{ call .T
+ `Use %s and start the server with the -Dminecraft.api.session.host
argument described above. For example, the full command you use to start the server might be:`
+ (html `OnlineModeFix`)
+ }}
java -Xmx1024M -Xms1024M \