localizer

package
v0.0.0-...-1591bef Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package localizer is used to localize for different languages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Localizer

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

Localizer is message.Printer instance for the locale.

func Get

func Get(lang string) *Localizer

Get gets the matched Localizer for the language. it will get the most matched language, see more: https://go.dev/blog/matchlang if the language is not supported by the server, then fall back to English. eg: language tags like zh-CN, zh-TW, zh-HK, cmn will use Chinese, other language tags like en-US, en-GB, nl or unknown language tag will use English.

func (*Localizer) Translate

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

Translate acts as a wrapper to call message.Printer's Sprintf method. it returns the appropriate translation for the given message and language. it is concurrency safe.

Jump to

Keyboard shortcuts

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