i18n

package
v0.0.0-...-38c13fd Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

i18n

i18n packages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMessage

func GetMessage(param interface{}) (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 Localize

func Localize(opts ...Option) gin.HandlerFunc

Localize ...

func MustGetMessage

func MustGetMessage(param interface{}) 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 GetLngHandler

type GetLngHandler = func(context *gin.Context, defaultLng string) string

GetLngHandler ...

type GinI18n

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

GinI18n ...

type Option

type Option func(GinI18n)

Option ...

func WithBundle

func WithBundle(config *BundleCfg) Option

WithBundle ...

func WithGetLngHandle

func WithGetLngHandle(handler GetLngHandler) Option

WithGetLngHandle ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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