locale

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ENUS for English in USA style
	ENUS lang = "en_US.UTF-8"
	// ZHCN for Chinese in China style
	ZHCN lang = "zh_CN.UTF-8"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Localer

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

Localer include of system languange and message set In linux the value of lang depend on systemctl env 'LANG'

func New

func New() *Localer

New implement a Localer

func (*Localer) AppendMsg

func (l *Localer) AppendMsg(lan lang, mS MsgSet) error

AppendMsg append a message set in prticular language

func (*Localer) GetLang

func (l *Localer) GetLang() string

GetLang get language of system return a string like locale ex.en_US.utf8 zh_CN.utf8

func (*Localer) GetMsg

func (l *Localer) GetMsg(msgKey string) string

GetMsg return message in system lang kind return english kind of message if system language isn.t exist in msgSets If messages ket isn't exist it will return ""

func (*Localer) GetMsgWithError

func (l *Localer) GetMsgWithError(msgKey string) (string, error)

GetMsgWithError return a message in system language kind If message sets isn't exist it will return message in English format return error if msgKey isn't exist in msgSet

func (*Localer) SetMsgs

func (l *Localer) SetMsgs(lan lang, mS MsgSet) error

SetMsgs set messages for tagert language

type MsgSet

type MsgSet map[string]string

MsgSet include of a message sets

Jump to

Keyboard shortcuts

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