i18n

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: AGPL-3.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const EN = "en-US"
View Source
const ZH = "zh-CN"

Variables

This section is empty.

Functions

func GetLocaleNameByRequest

func GetLocaleNameByRequest(request *http.Request) string

GetLocaleNameByRequest 从request获取语言名称

Types

type LocaleResource

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

func (*LocaleResource) ExistKey

func (locale *LocaleResource) ExistKey(key string) bool

func (*LocaleResource) Get

func (locale *LocaleResource) Get(key string, defaults ...string) string

func (*LocaleResource) GetTemplate

func (locale *LocaleResource) GetTemplate(key string) *Template

func (*LocaleResource) Name

func (locale *LocaleResource) Name() string

type LocaleResourceLoader

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

func NewLoader

func NewLoader() *LocaleResourceLoader

func (*LocaleResourceLoader) DefaultLocale

func (loader *LocaleResourceLoader) DefaultLocale(defaultLocale string)

func (*LocaleResourceLoader) LoadDir

func (loader *LocaleResourceLoader) LoadDir(dir string) error

func (*LocaleResourceLoader) LoadFile

func (loader *LocaleResourceLoader) LoadFile(fileList ...string) error

func (*LocaleResourceLoader) Locale

func (loader *LocaleResourceLoader) Locale(locales ...string) *LocaleResource

type Template

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

func NewTemplate

func NewTemplate(key string, content string) *Template

func (*Template) Content

func (t *Template) Content() string

func (*Template) Key

func (t *Template) Key() string

func (*Template) Render

func (t *Template) Render(args ...interface{}) string

func (*Template) RenderByKey

func (template *Template) RenderByKey(params map[string]string) string

RenderByKey 根据key名字渲染 eg: {{keyName}}

Jump to

Keyboard shortcuts

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