Documentation
¶
Overview ¶
Package gi18n 实现国际化和本地化。 md5:c7d7e3f7580f80a2
Package gi18n 实现国际化和本地化。 md5:c7d7e3f7580f80a2
Index ¶
- Constants
- func GetContent(ctx context.Context, key string) string
- func LanguageFromCtx(ctx context.Context) string
- func SetDelimiters(left, right string)
- func SetLanguage(language string)
- func SetPath(path string) error
- func T(ctx context.Context, content string) string
- func Tf(ctx context.Context, format string, values ...interface{}) string
- func Translate(ctx context.Context, content string) string
- func TranslateFormat(ctx context.Context, format string, values ...interface{}) string
- func WithLanguage(ctx context.Context, language string) context.Context
- type Manager
- func (m *Manager) GetContent(ctx context.Context, key string) string
- func (m *Manager) SetDelimiters(left, right string)
- func (m *Manager) SetLanguage(language string)
- func (m *Manager) SetPath(path string) error
- func (m *Manager) T(ctx context.Context, content string) string
- func (m *Manager) Tf(ctx context.Context, format string, values ...interface{}) string
- func (m *Manager) Translate(ctx context.Context, content string) string
- func (m *Manager) TranslateFormat(ctx context.Context, format string, values ...interface{}) string
- type Options
Constants ¶
View Source
const (
// DefaultName是实例使用的默认组名。 md5:ca8d8295a8c531f4
DefaultName = "default"
)
Variables ¶
This section is empty.
Functions ¶
func GetContent ¶
GetContent 获取并返回给定键和指定语言的配置内容。 如果未找到,将返回一个空字符串。 md5:c64a3a803ac07e38
func LanguageFromCtx ¶
LanguageFromCtx 从上下文中获取并返回语言名称。 如果之前未设置,则返回空字符串。 md5:f62999632f76669e
func SetDelimiters ¶
func SetDelimiters(left, right string)
SetDelimiters 为翻译器设置分隔符。 md5:f84b046b11204dc7
func TranslateFormat ¶
TranslateFormat 使用配置的语言和给定的 `values` 对 `format` 进行翻译、格式化并返回结果。 md5:2806a81d6db86c7f
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
i18n内容的管理器,它是并发安全的,支持热重载。 md5:9c519435bec8f5ad
func New ¶
New 创建并返回一个新的国际化管理器。 可选参数 `option` 用于指定国际化管理器的自定义选项。 如果未传递该参数,它将使用默认选项。 md5:79f31dcd2ff8cf56
func (*Manager) GetContent ¶
GetContent 获取并返回给定键和指定语言的配置内容。 如果未找到,将返回一个空字符串。 md5:c64a3a803ac07e38
func (*Manager) SetDelimiters ¶
SetDelimiters 为翻译器设置分隔符。 md5:f84b046b11204dc7
func (*Manager) SetLanguage ¶
SetLanguage 设置翻译器的语言。 md5:50b09b0bb0944dc1
Click to show internal directories.
Click to hide internal directories.