Add translation system (#104)

This commit is contained in:
Thomas Miceli
2023-09-22 17:26:09 +02:00
committed by GitHub
parent 61e274e56d
commit a5ea522e45
27 changed files with 774 additions and 205 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/labstack/echo/v4"
"github.com/thomiceli/opengist/internal/config"
"github.com/thomiceli/opengist/internal/db"
"github.com/thomiceli/opengist/internal/i18n"
"golang.org/x/crypto/argon2"
"html/template"
"net/http"
@ -212,11 +213,11 @@ func paginate[T any](ctx echo.Context, data []*T, pageInt int, perPage int, temp
switch labels {
case 1:
setData(ctx, "prevLabel", "Previous")
setData(ctx, "nextLabel", "Next")
setData(ctx, "prevLabel", tr(ctx, "pagination.previous"))
setData(ctx, "nextLabel", tr(ctx, "pagination.next"))
case 2:
setData(ctx, "prevLabel", "Newer")
setData(ctx, "nextLabel", "Older")
setData(ctx, "prevLabel", tr(ctx, "pagination.newer"))
setData(ctx, "nextLabel", tr(ctx, "pagination.older"))
}
setData(ctx, "urlPage", urlPage)
@ -224,6 +225,11 @@ func paginate[T any](ctx echo.Context, data []*T, pageInt int, perPage int, temp
return nil
}
func tr(ctx echo.Context, key string) template.HTML {
l := getData(ctx, "locale").(*i18n.Locale)
return l.Tr(key)
}
type Argon2ID struct {
format string
version int