Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LocalizeConfig ¶ added in v1.0.5
Localize config.
type Localizer ¶
type Localizer struct {
// contains filtered or unexported fields
}
Localizer defines the structure for managing language localization.
func GetLocalizer ¶
func GetLocalizer() *Localizer
GetLocalizer returns the current global Localizer instance.
func (*Localizer) GetAvailableLanguages ¶
GetAvailableLanguages returns a list of all available languages for the localizer.
func (*Localizer) GetDefaultLanguage ¶
GetDefaultLanguage returns the default language used by the localizer when no language is specified.
func (*Localizer) NewTranslator ¶
func (l *Localizer) NewTranslator(lang string) Translator
NewTranslator returns a Translator for the specified language.
If the language is not found and it is not the default language, it will fall back to the default language.
The Translator is a function that takes a key and optional parameters to translate the key into a message in the specified language.
The optional parameters are:
- PluralCount: the count of items to pluralize the message.
- TemplateData: the data to be used to replace placeholders in the message.
If the key is not found, it will return the key itself.
If the language is not found, it will return the default message.
type Translator ¶
type Translator func(key string, configs ...*LocalizeConfig) string
Translation model.