Documentation ¶
Index ¶
- Constants
- func FetchCurrentLanguageFromCtx(ctx context.Context) (*language.Tag, bool)
- func FormatMessage(ctx context.Context, message *i18n2.Message, args map[string]interface{}) string
- func FormatText(ctx context.Context, msgId string, defaultText string) string
- func FormatTextWithData(ctx context.Context, msgId string, defaultText string, ...) string
- func IsHasI18n(ctx context.Context) bool
- func LocalizedString(ctx context.Context, defaultValue string, langMap map[language.Tag]string) string
- func MatchCurrentLanguageTag(accept string, supportTags []language.Tag) language.Tag
- func NewBundle(tag language.Tag, configs ...string) *i18n2.Bundle
- func SetDefaultErrCode(code uint32)
- func SetDefaultLangHeaderKey(key string)
- func WithRpcInterceptorDebug(debug bool)
- type I18nGrpcInterceptor
- type I18nMiddleware
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 FormatMessage ¶
func FormatTextWithData ¶
func LocalizedString ¶ added in v0.2.1
func MatchCurrentLanguageTag ¶ added in v0.2.0
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 ¶
func (m *I18nMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc
Click to show internal directories.
Click to hide internal directories.