lang

package
v0.0.0-...-fc17aaa Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIds

func GetIds() []string

func GetMessage

func GetMessage(param interface{}, lng ...string) (string, error)

GetMessage get the i18n message

 param is one of these type: messageID, *i18n.LocalizeConfig
 Example:
	GetMessage("hello") // messageID is hello
	GetMessage(&i18n.LocalizeConfig{
			MessageID: "welcomeWithName",
			TemplateData: map[string]string{
				"name": context.Param("name"),
			},
	})

func MustGetMessage

func MustGetMessage(param interface{}, lng ...string) string

MustGetMessage get the i18n message without error handling

  param is one of these type: messageID, *i18n.LocalizeConfig
  Example:
	MustGetMessage("hello") // messageID is hello
	MustGetMessage(&i18n.LocalizeConfig{
			MessageID: "welcomeWithName",
			TemplateData: map[string]string{
				"name": context.Param("name"),
			},
	})

Types

type BundleCfg

type BundleCfg struct {
	DefaultLanguage  language.Tag
	FormatBundleFile string
	AcceptLanguage   []language.Tag
	RootPath         string
	UnmarshalFunc    i18n.UnmarshalFunc
}

BundleCfg ...

type I18n

type I18n interface {
	// contains filtered or unexported methods
}

func Init

func Init(langPath string, defaultLang language.Tag, accepts ...language.Tag) I18n

type Option

type Option func(I18n)

Option ...

func WithBundle

func WithBundle(config *BundleCfg) Option

WithBundle ...

Jump to

Keyboard shortcuts

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