Help us shape the future of Go! Take the 2026 Go Developer Survey

localization

package
v3.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractLanguageFromGrpcRequest

func ExtractLanguageFromGrpcRequest(ctx context.Context) []string

func ExtractLanguageFromHTTPHeader

func ExtractLanguageFromHTTPHeader(req http.Header) []string

func ExtractLanguageFromHTTPRequest

func ExtractLanguageFromHTTPRequest(req *http.Request) []string

func FromContext

func FromContext(ctx context.Context) []string

FromContext extracts language from the supplied context if any exist.

func FromMap

func FromMap(m map[string]string) []string

func ToContext

func ToContext(ctx context.Context, lang []string) context.Context

ToContext adds language to the current supplied context.

func ToMap

func ToMap(m map[string]string, lang []string) map[string]string

Types

type Manager

type Manager interface {
	Bundle() *i18n.Bundle
	Translate(ctx context.Context, request any, messageID string) string
	TranslateWithMap(
		ctx context.Context,
		request any,
		messageID string,
		variables map[string]any,
	) string
	TranslateWithMapAndCount(
		ctx context.Context,
		request any,
		messageID string,
		variables map[string]any,
		count int,
	) string
}

func NewManager

func NewManager(translationsFolder string, languages ...string) Manager

NewManager Option to initialize/loadOIDC different language packs.

Directories

Path Synopsis
interceptors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL