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 }, } )