Documentation ¶
Overview ¶
Package gi18n implements internationalization and localization.
Package gi18n 实现了国际化和本地化功能。
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 是用于实例使用的默认组名。
DefaultName = "default"
)
Variables ¶
This section is empty.
Functions ¶
func GetContent ¶
GetContent 函数根据给定的键和指定的语言获取并返回配置的内容。 如果未找到,则返回一个空字符串。
func LanguageFromCtx ¶
LanguageFromCtx 从context中获取并返回语言名称。 如果此前未设置,则返回一个空字符串。
func TranslateFormat ¶
TranslateFormat 将根据配置的语言和给定的 `values` 对 `format` 进行翻译、格式化并返回结果。
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
i18n内容的管理器,它是并发安全的,并支持热重载。
func (*Manager) GetContent ¶
GetContent 函数根据给定的键和指定的语言获取并返回配置的内容。 如果未找到,则返回一个空字符串。
func (*Manager) SetDelimiters ¶
SetDelimiters 设置翻译器的分隔符。
Click to show internal directories.
Click to hide internal directories.