You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool-biz/core/i18n/vars.go

38 lines
866 B
Go

package i18n
import (
"context"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
"os"
)
const (
KeyLang = "lang"
KeyAcceptLanguage = "Accept-Language"
defaultRootPath = "locale"
)
var (
defaultLanguage = language.Chinese
defaultBundleConfig = BundleConfig{
DefaultLanguage: defaultLanguage,
RootPath: defaultRootPath,
FileLoader: LoaderFunc(os.ReadFile),
//
SortedParameterPrefix: "p",
//
TagGetter: func(context context.Context) string {
if v, ok := context.Value(KeyLang).(string); ok {
return v
}
return defaultLanguage.String()
},
LocalizeConfigGetter: func(config BundleConfig, param any) *i18n.LocalizeConfig {
return nil
},
}
)