Documentation ¶
Index ¶
- func NewContext(ctx context.Context, i *I18n) context.Context
- func WithFS(fs embed.FS) func(*Options)
- func WithFile(f string) func(*Options)
- func WithFormat(format string) func(*Options)
- func WithLanguage(lang language.Tag) func(*Options)
- type I18n
- func (i *I18n) Add(f string)
- func (i *I18n) AddFS(fs embed.FS)
- func (i I18n) E(id string) error
- func (i I18n) Language() language.Tag
- func (i I18n) LocalizeE(message *i18n.Message) error
- func (i I18n) LocalizeT(message *i18n.Message) (rp string)
- func (i I18n) Select(lang language.Tag) *I18n
- func (i I18n) T(id string) (rp string)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithFormat ¶
func WithLanguage ¶
Types ¶
type I18n ¶
type I18n struct {
// contains filtered or unexported fields
}
I18n is used to store the options and configurations for internationalization.
func FromContext ¶
func New ¶
New creates a new instance of the I18n struct with the given options. It takes a variadic parameter of functional options and returns a pointer to the I18n struct.
func (I18n) E ¶
E is a wrapper for T that converts the localized string to an error type and returns it.
func (I18n) LocalizeE ¶
LocalizeE is a wrapper for LocalizeT method that converts the localized string to an error type and returns it.
Click to show internal directories.
Click to hide internal directories.