Language Toggle

En/ Ru

Language Toggle

Locale switcher (app toggles package).

github.com/fastygo/templ/ui

Locale switcher (app toggles package).

Default

import "github.com/fastygo/framework/pkg/web/view"
import toggles "github.com/fastygo/ui/internal/ui/components/toggles"

templ Example() {
	@toggles.LanguageToggle(view.LanguageToggleData{
		CurrentLabel:     "EN",
		CurrentLocale:    "en",
		NextLocale:       "ru",
		NextHref:         "/?lang=ru",
		DefaultLocale:    "en",
		AvailableLocales: []string{"en", "ru"},
		Label:            "Switch language",
	})
}

API

CurrentLabel · string — Visible label

NextHref · string — Link to next locale

CurrentLocale · string — Active locale code