localizer

package
v0.0.0-...-dc3a213 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLang string = "en"

DefaultLang stores the default language for translations

Functions

func SetDefaultLang

func SetDefaultLang(lang string)

SetDefaultLang sets the DefaultLang variable

Types

type Localizer

type Localizer struct {
	ID string
	// contains filtered or unexported fields
}

Localizer is a type which stores the relevant locale ID (as used in our URLs) and a (deliberately unexported) message.Printer instance for the locale.

func Get

func Get(id string) (*Localizer, bool)

Get function accepts a locale ID and returns the corresponding Localizer for that locale. If the locale ID is not supported then this returns `false` as the second return value.

func GetGlobal

func GetGlobal(id string) *Localizer

GetGlobal returns a message.Printer based on the default catalog. This is just a helper for outside applications using gobwebs

func (*Localizer) Translate

func (l *Localizer) Translate(key message.Reference, args ...any) string

Translate method to the Localizer type. This acts as a wrapper around the unexported message.Printer's Sprintf() function and returns the appropriate translation for the given message and arguments.

Jump to

Keyboard shortcuts

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