Internationalization (i18n)
Ship multi-language apps out of the box with locale detection, translation file management, and a built-in language selector.
Features
- Enabled by default (
I18N_ENABLED=true); applied globally inroutes.go - Locale resolution order:
LOCALE_COOKIE_NAMEcookie →Accept-Languageheader →DEFAULT_LOCALE - Default supported locales are English (
en) and Spanish (es), configurable viaSUPPORTED_LOCALES - Generated apps embed translations under
locales/<code>/<code>.yamland load them ininit.regius.go - Add new locales with
regius make locale <code>(e.g.regius make locale fr)
Usage in Templ Views
import "github.com/hbarral/regius/i18n"
templ Hello(name string) {
<p>{ i18n.T(ctx, "navbar.welcome", i18n.M{"name": name}) }</p>
}
Usage in Jet/Go Templates
<p>{{T "navbar.home"}}</p>
<html lang="{{.Locale}}">
Environment Variables
I18N_ENABLED=true
DEFAULT_LOCALE=en
SUPPORTED_LOCALES=en,es
LOCALE_COOKIE_NAME=locale