Documentation
¶
Overview ¶
Package i18n provides native multi-language support for PaperValet. Every user-facing string should go through the catalog.
Index ¶
- func WithLang(ctx context.Context, l Lang) context.Context
- type Catalog
- func (c *Catalog) Add(l Lang, key, template string)
- func (c *Catalog) AddMany(l Lang, entries map[string]string)
- func (c *Catalog) Default() Lang
- func (c *Catalog) Has(l Lang, key string) bool
- func (c *Catalog) Keys(l Lang) []string
- func (c *Catalog) Languages() []Lang
- func (c *Catalog) Merge(other *Catalog)
- func (c *Catalog) SetDefault(l Lang)
- func (c *Catalog) T(l Lang, key string, args ...any) string
- type Lang
- type Manager
- func (m *Manager) Catalog() *Catalog
- func (m *Manager) ClearUserLangs()
- func (m *Manager) SetUserLang(userID int64, l Lang)
- func (m *Manager) T(userID int64, key string, args ...any) string
- func (m *Manager) TContext(ctx context.Context, userID int64, key string, args ...any) string
- func (m *Manager) UserLang(userID int64) Lang
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is a translation table: lang -> key -> template. Templates use {0}, {1} style placeholders.
func CoreCatalog ¶
func CoreCatalog() *Catalog
func SetupCatalog ¶ added in v0.1.1
func SetupCatalog() *Catalog
SetupCatalog holds the strings of the terminal `initialize` flow. It is separate from CoreCatalog because it is only needed before the bot runs.
func (*Catalog) SetDefault ¶
SetDefault changes the default language.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds the catalog plus per-user language preferences.
func NewManager ¶
NewManager creates a language manager over a catalog.
func (*Manager) ClearUserLangs ¶ added in v0.1.1
func (m *Manager) ClearUserLangs()
ClearUserLangs drops per-user overrides so the catalog default applies.
func (*Manager) SetUserLang ¶
SetUserLang records a user's preferred language.
Click to show internal directories.
Click to hide internal directories.