tbs

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 9 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear clear all loaded text resources

func Format

func Format(locale, format string, args ...any) string

Format translate content to target language.

func Get

func Get(locale, section, name string) (string, bool)

Get target locale string

func GetBundle

func GetBundle(locale string) *ini.Ini

GetBundle get target locale ini bundle

func Load

func Load(root string) error

Load glob and parse text files under root path

func LoadFS

func LoadFS(fsys fs.FS, root string) error

LoadFS glob and parse template files from FS

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) Clear

func (tbs *TextBundles) Clear()

Clear clear all loaded text resources

func (*TextBundles) Format

func (tbs *TextBundles) Format(locale, format string, args ...any) string

Format translate content to target language.

func (*TextBundles) Get

func (tbs *TextBundles) Get(locale, section, name string) (string, bool)

Get target locale string

func (*TextBundles) GetBundle

func (tbs *TextBundles) GetBundle(locale string) *ini.Ini

GetBundle get target locale ini bundle

func (*TextBundles) Load

func (tbs *TextBundles) Load(root string) error

Load glob and parse text files under root path

func (*TextBundles) LoadFS

func (tbs *TextBundles) LoadFS(fsys fs.FS, root string) error

LoadFS glob and parse template files from FS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL