Skip to main content

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 in routes.go
  • Locale resolution order: LOCALE_COOKIE_NAME cookie → Accept-Language header → DEFAULT_LOCALE
  • Default supported locales are English (en) and Spanish (es), configurable via SUPPORTED_LOCALES
  • Generated apps embed translations under locales/<code>/<code>.yaml and load them in init.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