i18n

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 10 Imported by: 2 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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