Documentation
¶
Overview ¶
Package i18n provides tanGO's small text-translation primitives.
It is intentionally an override layer: callers keep English fallback text inline in source, while registered catalogs provide translated replacements for stable symbolic keys.
Index ¶
- func DefaultLocaleResolver(r *http.Request) string
- func Locale(ctx context.Context) string
- func Middleware(resolver LocaleResolver) tango.Middleware
- func RegisterCatalog(locale string, catalog map[string]string)
- func T(ctx context.Context, key, fallback string, args ...any) string
- func WithLocale(ctx context.Context, locale string) context.Context
- type LocaleResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLocaleResolver ¶
DefaultLocaleResolver resolves the request locale from Accept-Language, using the registered catalogs as the set of supported locales.
func Middleware ¶
func Middleware(resolver LocaleResolver) tango.Middleware
Middleware stores the locale resolved for each request on the request's context so later T calls can observe it. A nil resolver uses DefaultLocaleResolver.
func RegisterCatalog ¶
RegisterCatalog merges catalog into the existing catalog for locale. Registering the same key again replaces that key's previous value; other keys and other locales are left untouched.
Types ¶
type LocaleResolver ¶
LocaleResolver resolves the active locale for one incoming request.