goi18n

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

goi18n

i18n for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Goi18n

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

Goi18n is a struct for i18n.

func New

func New(opt *Option) *Goi18n

New creates a new Goi18n.

func (*Goi18n) GetDescriptionByIndex

func (g *Goi18n) GetDescriptionByIndex(index int) string

GetLangDescByIndex Get language description by index id.

func (*Goi18n) GetDescriptionByLang

func (g *Goi18n) GetDescriptionByLang(lang string) string

GetLangDescByLang Get language description by language.

func (*Goi18n) GetLangByIndex

func (g *Goi18n) GetLangByIndex(index int) string

GetLangByIndex Get language by index id.

func (*Goi18n) GetLanguageLength

func (g *Goi18n) GetLanguageLength() int

GetLanguageLength returns the length of languages.

func (*Goi18n) IndexLang

func (g *Goi18n) IndexLang(lang string) int

IndexLang returns the index of language.

func (*Goi18n) IsExist

func (g *Goi18n) IsExist(lang string) bool

IsExist returns whether the language is exist.

func (*Goi18n) ListLangDescs

func (g *Goi18n) ListLangDescs() []string

ListLangDescs returns all language descriptions.

func (*Goi18n) ListLangs

func (g *Goi18n) ListLangs() []string

ListLangs returns all languages.

func (*Goi18n) Reload

func (g *Goi18n) Reload(langs ...string) error

Reload locales

func (*Goi18n) SetLangDesc

func (g *Goi18n) SetLangDesc(lang string, desc string)

SetLangDesc sets the language description.

func (*Goi18n) SetLanguage

func (g *Goi18n) SetLanguage(lang string, desc string) bool

SetLanguage sets the language.

func (*Goi18n) T added in v0.0.3

func (g *Goi18n) T(key string) string

T returns the translation of key by default language.

func (*Goi18n) Translate

func (g *Goi18n) Translate(lang string, key string) string

Translate translate by given language.

type Option

type Option struct {
	Path     string
	Language string
}

Option is the option of Goi18n.

func DefaultOption

func DefaultOption() *Option

DefaultOption returns the default option.

Jump to

Keyboard shortcuts

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