feat: implement localization system (#716)
* lib/localization: implement localization system Locale files are placed in lib/localization/locales/. If you add a locale, update manifest.json with available locales. * Exclude locales from check spelling * tests(lib/localization): add comprehensive translations test Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(challenge/metarefresh): enable localization Signed-off-by: Xe Iaso <me@xeiaso.net> * fix: use simple syntax for localization in templ Also localize CELPHASE into French according to the wishes of the artist. Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: spelling Signed-off-by: Xe Iaso <me@xeiaso.net> * chore:(js): fix forbidden patterns Signed-off-by: Xe Iaso <me@xeiaso.net> * chore: add goi18n to tools Signed-off-by: Xe Iaso <me@xeiaso.net> * test(lib/localization): dynamically determine the list of supported languages Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
c2423d0688
commit
ad5430612f
24 changed files with 1205 additions and 314 deletions
21
web/index.go
21
web/index.go
|
|
@ -3,31 +3,32 @@ package web
|
|||
import (
|
||||
"github.com/a-h/templ"
|
||||
|
||||
"github.com/TecharoHQ/anubis/lib/localization"
|
||||
"github.com/TecharoHQ/anubis/lib/policy/config"
|
||||
)
|
||||
|
||||
func Base(title string, body templ.Component, impressum *config.Impressum) templ.Component {
|
||||
return base(title, body, impressum, nil, nil)
|
||||
func Base(title string, body templ.Component, impressum *config.Impressum, localizer *localization.SimpleLocalizer) templ.Component {
|
||||
return base(title, body, impressum, nil, nil, localizer)
|
||||
}
|
||||
|
||||
func BaseWithChallengeAndOGTags(title string, body templ.Component, impressum *config.Impressum, challenge string, rules *config.ChallengeRules, ogTags map[string]string) (templ.Component, error) {
|
||||
func BaseWithChallengeAndOGTags(title string, body templ.Component, impressum *config.Impressum, challenge string, rules *config.ChallengeRules, ogTags map[string]string, localizer *localization.SimpleLocalizer) (templ.Component, error) {
|
||||
return base(title, body, impressum, struct {
|
||||
Rules *config.ChallengeRules `json:"rules"`
|
||||
Challenge string `json:"challenge"`
|
||||
}{
|
||||
Challenge: challenge,
|
||||
Rules: rules,
|
||||
}, ogTags), nil
|
||||
}, ogTags, localizer), nil
|
||||
}
|
||||
|
||||
func Index() templ.Component {
|
||||
return index()
|
||||
func Index(localizer *localization.SimpleLocalizer) templ.Component {
|
||||
return index(localizer)
|
||||
}
|
||||
|
||||
func ErrorPage(msg string, mail string) templ.Component {
|
||||
return errorPage(msg, mail)
|
||||
func ErrorPage(msg string, mail string, localizer *localization.SimpleLocalizer) templ.Component {
|
||||
return errorPage(msg, mail, localizer)
|
||||
}
|
||||
|
||||
func Bench() templ.Component {
|
||||
return bench()
|
||||
func Bench(localizer *localization.SimpleLocalizer) templ.Component {
|
||||
return bench(localizer)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue