i18n

package
v0.3.10-0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 15

Documentation

Index

Constants

View Source
const (
	LangHeader = "X-Yunion-Lang"
)

Variables

This section is empty.

Functions

func Lang

func Lang(ctx context.Context) language.Tag

func P

func P(tag language.Tag, id string, a ...interface{}) string

func SetHTTPLangHeader

func SetHTTPLangHeader(ctx context.Context, header http.Header) bool

func WithLang

func WithLang(ctx context.Context, lang string) context.Context

func WithLangTag

func WithLangTag(ctx context.Context, tag language.Tag) context.Context

func WithRequestLang

func WithRequestLang(ctx context.Context, req *http.Request) context.Context

Types

type ITable

type ITable interface {
	Lookup(ctx context.Context, key string) string
}

type Table

type Table map[string]TableEntry

func (Table) Lookup

func (tbl Table) Lookup(ctx context.Context, key string) string

func (Table) LookupByLang

func (tbl Table) LookupByLang(lang language.Tag, key string) string

func (Table) Set

func (tbl Table) Set(k string, te TableEntry)

type TableEntry

type TableEntry map[language.Tag]string

func NewTableEntry

func NewTableEntry() TableEntry

func (TableEntry) CN

func (te TableEntry) CN(v string) TableEntry

func (TableEntry) EN

func (te TableEntry) EN(v string) TableEntry

func (TableEntry) Lookup

func (te TableEntry) Lookup(ctx context.Context) (string, bool)

type Tag

type Tag = language.Tag
var (
	I18N_TAG_CHINESE Tag = Tag(language.Chinese)
	I18N_TAG_ENGLISH Tag = Tag(language.English)
)

Jump to

Keyboard shortcuts

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