18 lines
410 B
Go
18 lines
410 B
Go
// Package i18n is used to localize for different languages
|
|
package i18n
|
|
|
|
import "context"
|
|
|
|
type acceptLangKey struct{}
|
|
|
|
// SetLang 设定语言
|
|
func SetLang(ctx context.Context, val string) context.Context {
|
|
return context.WithValue(ctx, acceptLangKey{}, val)
|
|
}
|
|
|
|
// GetLang 获取语言
|
|
func GetLang(ctx context.Context) (string, bool) {
|
|
value, ok := ctx.Value(acceptLangKey{}).(string)
|
|
return value, ok
|
|
}
|