localizer

package
v0.0.0-...-e2fe045 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Localizer

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

Define a Localizer 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) (l *Localizer, ok bool)

The 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 GetLocaleList

func GetLocaleList() []*Localizer

Get locales array

func (l *Localizer) Link(r *http.Request) string

func (*Localizer) LinkTo

func (l *Localizer) LinkTo(path string) string

func (*Localizer) Translate

func (l *Localizer) Translate(key message.Reference, args ...interface{}) string

We also add a 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