goi18nx

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const I18nCurrentLangKey = "SpectatorNan/goi18nx/currentLang"
View Source
const I18nKey = "SpectatorNan/goi18nx"

Variables

This section is empty.

Functions

func FetchCurrentLanguageFromCtx added in v0.2.0

func FetchCurrentLanguageFromCtx(ctx context.Context) (*language.Tag, bool)

func FormatMessage

func FormatMessage(ctx context.Context, message *i18n2.Message, args map[string]interface{}) string

func FormatText

func FormatText(ctx context.Context, msgId string, defaultText string) string

func FormatTextWithData

func FormatTextWithData(ctx context.Context, msgId string, defaultText string, args map[string]interface{}) string

func IsHasI18n added in v0.1.3

func IsHasI18n(ctx context.Context) bool

func LocalizedString added in v0.2.1

func LocalizedString(ctx context.Context, defaultValue string, langMap map[language.Tag]string) string

func MatchCurrentLanguageTag added in v0.2.0

func MatchCurrentLanguageTag(accept string, supportTags []language.Tag) language.Tag

func NewBundle

func NewBundle(tag language.Tag, configs ...string) *i18n2.Bundle

func SetDefaultErrCode added in v0.1.3

func SetDefaultErrCode(code uint32)

SetDefaultErrCode sets the default value of the err code. need to be set before use

func SetDefaultLangHeaderKey added in v0.1.1

func SetDefaultLangHeaderKey(key string)

SetDefaultLangHeaderKey sets the default value of the lang header key. need to be set before use

func WithRpcInterceptorDebug added in v0.2.3

func WithRpcInterceptorDebug(debug bool)

Types

type I18nGrpcInterceptor added in v0.1.3

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

func NewI18nGrpcInterceptor added in v0.1.3

func NewI18nGrpcInterceptor(supportTags []language.Tag, localizationFiles []string) *I18nGrpcInterceptor

func (*I18nGrpcInterceptor) Interceptor added in v0.1.3

func (i *I18nGrpcInterceptor) Interceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

type I18nMiddleware

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

func NewI18nMiddleware

func NewI18nMiddleware(supportTags []language.Tag, localizationFiles []string) *I18nMiddleware

func (*I18nMiddleware) Handle

Jump to

Keyboard shortcuts

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