Documentation ¶
Index ¶
- func Clear()
- func Format(locale, format string, args ...any) string
- func GetBool(locale, key string, defs ...bool) bool
- func GetBundle(locale string) *ini.Ini
- func GetFloat(locale, key string, defs ...float64) float64
- func GetInt(locale, key string, defs ...int) int
- func GetInt64(locale, key string, defs ...int64) int64
- func GetText(locale, key string, defs ...string) string
- func Load(root string) error
- func LoadFS(fsys fs.FS, root string) error
- func Replace(locale, format string, args ...any) string
- func SetDefault(tbs *TextBundles)
- type TextBundles
- func (tbs *TextBundles) Clear()
- func (tbs *TextBundles) Format(locale, format string, args ...any) string
- func (tbs *TextBundles) GetBool(locale, key string, defs ...bool) bool
- func (tbs *TextBundles) GetBundle(locale string) *ini.Ini
- func (tbs *TextBundles) GetFloat(locale, key string, defs ...float64) float64
- func (tbs *TextBundles) GetInt(locale, key string, defs ...int) int
- func (tbs *TextBundles) GetInt64(locale, key string, defs ...int64) int64
- func (tbs *TextBundles) GetText(locale, key string, defs ...string) string
- func (tbs *TextBundles) Load(root string) error
- func (tbs *TextBundles) LoadFS(fsys fs.FS, root string) error
- func (tbs *TextBundles) Replace(locale, format string, args ...any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBool ¶ added in v1.0.10
GetBool get a bool value of the key from the text bundle. if not found or convert error, returns the default defs[0] bool value
func GetFloat ¶ added in v1.0.10
GetFloat get a float64 value of the key from the text bundle. if not found or convert error, returns the default defs[0] float64 value
func GetInt ¶ added in v1.0.10
GetInt get a int value of the key from the text bundle. if not found or convert error, returns the default defs[0] int value
func GetInt64 ¶ added in v1.0.10
GetInt64 get a int64 value of the key from the text bundle. if not found or convert error, returns the default defs[0] int64 value
func Replace ¶ added in v1.0.10
Replace use strings.Replacer to translate content to the locale language.
func SetDefault ¶
func SetDefault(tbs *TextBundles)
SetDefault set the default TextBundles instance used by the package-level functions.
Types ¶
type TextBundles ¶
type TextBundles struct { Extensions []string // file extensions Timestamp time.Time // modified timestamp // contains filtered or unexported fields }
TextBundles a localized text resource bundle container
func Default ¶
func Default() *TextBundles
Default returns the default TextBundles instance used by the package-level functions.
func NewTextBundles ¶
func NewTextBundles(extensions ...string) *TextBundles
NewTextBundles returns a new TextBundles instance
func (*TextBundles) Format ¶
func (tbs *TextBundles) Format(locale, format string, args ...any) string
Format use fmt.Sprrintf to translate content to the locale language.
func (*TextBundles) GetBool ¶ added in v1.0.10
func (tbs *TextBundles) GetBool(locale, key string, defs ...bool) bool
GetBool get a bool value of the key from the text bundle. if not found or convert error, returns the default defs[0] bool value
func (*TextBundles) GetBundle ¶
func (tbs *TextBundles) GetBundle(locale string) *ini.Ini
GetBundle get target locale ini bundle
func (*TextBundles) GetFloat ¶ added in v1.0.10
func (tbs *TextBundles) GetFloat(locale, key string, defs ...float64) float64
GetFloat get a float64 value of the key from the text bundle. if not found or convert error, returns the default defs[0] float64 value
func (*TextBundles) GetInt ¶ added in v1.0.10
func (tbs *TextBundles) GetInt(locale, key string, defs ...int) int
GetInt get a int value of the key from the text bundle. if not found or convert error, returns the default defs[0] int value
func (*TextBundles) GetInt64 ¶ added in v1.0.10
func (tbs *TextBundles) GetInt64(locale, key string, defs ...int64) int64
GetInt64 get a int64 value of the key from the text bundle. if not found or convert error, returns the default defs[0] int64 value
func (*TextBundles) GetText ¶ added in v1.0.10
func (tbs *TextBundles) GetText(locale, key string, defs ...string) string
GetText get the locale text by key.
func (*TextBundles) Load ¶
func (tbs *TextBundles) Load(root string) error
Load glob and parse text files under root path