Documentation ¶
Index ¶
- Variables
- func Build(c Config) error
- func Get(lang, templateKey string, defaultTemplate ...string) string
- func GetTemplate(lang, templateKey string, defaultTemplate ...string) (*template.Template, error)
- func MustRender(lang, templateKey string, data interface{}, defaultTemplate ...string) string
- func Render(lang, templateKey string, data interface{}, defaultTemplate ...string) (string, error)
- type Config
- type LanguageBundle
- func (l LanguageBundle) Get(lang, key string, defaultValue ...string) string
- func (l LanguageBundle) GetTemplate(lang, templateKey string, defaultTemplate ...string) (*template.Template, error)
- func (l LanguageBundle) MustRender(lang, templateKey string, data interface{}, defaultTemplate ...string) string
- func (l LanguageBundle) Render(lang, templateKey string, data interface{}, defaultTemplate ...string) (string, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFileExtensionNotSupport = errors.New("file extension not support")
View Source
var ErrInvalidLanguage = errors.New("invalid language")
View Source
var ErrInvalidLanguageData = errors.New("invalid language data")
View Source
var ErrRootBundleDoesNotInit = errors.New("root bundle does not init")
Functions ¶
func GetTemplate ¶
func MustRender ¶
Types ¶
type Config ¶
type Config struct { DefaultLanguage string `json:"defaultLanguage" yaml:"defaultLanguage"` LanguagePaths map[string][]string `json:"languagePaths" yaml:"languagePaths"` DataInject map[string]map[string]string `json:"dataInject" yaml:"dataInject"` Delimiter string `json:"delimiters" yaml:"delimiters"` }
func (Config) Build ¶
func (c Config) Build() (*LanguageBundle, error)
type LanguageBundle ¶
type LanguageBundle struct {
// contains filtered or unexported fields
}
func (LanguageBundle) Get ¶
func (l LanguageBundle) Get(lang, key string, defaultValue ...string) string
func (LanguageBundle) GetTemplate ¶
func (LanguageBundle) MustRender ¶
func (l LanguageBundle) MustRender(lang, templateKey string, data interface{}, defaultTemplate ...string) string
Click to show internal directories.
Click to hide internal directories.