Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator loads and resolves translated messages by locale.
func NewTranslator ¶
func NewTranslator(fallback string) *Translator
NewTranslator returns an empty translator with the given fallback locale.
func (*Translator) Get ¶
func (t *Translator) Get(locale, key string, args ...interface{}) string
Get resolves a translation key for the given locale. If the key is not found in the requested locale, the fallback locale is tried. If still not found, the raw key is returned. When args are provided, the first element is used as template data for text/template interpolation.
func (*Translator) LoadDir ¶
func (t *Translator) LoadDir(dir string) error
LoadDir loads all *.json files from a directory. Each file's name (without extension) is used as the locale.
func (*Translator) LoadFile ¶
func (t *Translator) LoadFile(locale, path string) error
LoadFile reads a JSON translation file and stores it under the given locale.
Click to show internal directories.
Click to hide internal directories.