language

package
v1.2.26 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 322

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EN   = language.English.String()
	CN   = language.Chinese.String()
	JP   = language.Japanese.String()
	TC   = language.TraditionalChinese.String()
	PTBR = language.BrazilianPortuguese.String()
)
View Source
var Lang = LangMap{
	language.Chinese.String():             cn,
	language.English.String():             en,
	language.Japanese.String():            jp,
	language.TraditionalChinese.String():  tc,
	language.BrazilianPortuguese.String(): ptbr,

	"cn":    cn,
	"en":    en,
	"jp":    jp,
	"tc":    tc,
	"pt-br": ptbr,
}

Lang is the global LangMap.

View Source
var Langs = [...]string{EN, CN, JP, TC}

Functions

func Add

func Add(key string, lang map[string]string)

Add add a language package to the Lang.

func AppendTo added in v1.2.18

func AppendTo(lang string, set map[string]string)

AppendTo add more language translations to the given language set.

func FixedLanguageKey added in v1.2.8

func FixedLanguageKey(key string) string

func Get

func Get(value string) string

Get return the value of default scope.

func GetFromHtml

func GetFromHtml(value template.HTML, scopes ...string) template.HTML

GetFromHtml return the value of given scopes and template.HTML value.

func GetWithLang added in v1.2.18

func GetWithLang(value, lang string) string

GetWithLang return the value of given language set.

func GetWithScope added in v1.0.0

func GetWithScope(value string, scopes ...string) string

GetWithScope return the value of given scopes.

func GetWithScopeAndLanguageSet added in v1.2.18

func GetWithScopeAndLanguageSet(value, lang string, scopes ...string) string

GetWithScopeAndLanguageSet return the value of given scopes and language set.

func JoinScopes added in v1.1.6

func JoinScopes(scopes []string) string

func WithScopes added in v1.0.0

func WithScopes(value string, scopes ...string) string

WithScopes join scopes prefix and the value.

Types

type LangMap

type LangMap map[string]LangSet

LangMap is the map of language packages.

func (LangMap) Get

func (lang LangMap) Get(value string) string

Get get the value from LangMap.

func (LangMap) GetWithScope added in v1.0.0

func (lang LangMap) GetWithScope(value string, scopes ...string) string

GetWithScope get the value from LangMap with given scopes.

type LangSet added in v1.2.8

type LangSet map[string]string

func (LangSet) Add added in v1.2.8

func (l LangSet) Add(key, value string)

func (LangSet) Combine added in v1.2.8

func (l LangSet) Combine(set LangSet) LangSet

Jump to

Keyboard shortcuts

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