Documentation ¶
Index ¶
- func GetLanguage() string
- func Initialize(locale *gotext.Locale) error
- func LoadTranslations() (*gotext.Locale, error)
- func SetLanguage(language string)
- type Translator
- func (t *Translator) Errorf(msgid string, vars ...interface{}) error
- func (t *Translator) NErrorf(msgid, msgidPlural string, n int, vars ...interface{}) error
- func (t *Translator) NT(msgid, msgidPlural string, n int, vars ...interface{}) string
- func (t *Translator) T(msgid string, vars ...interface{}) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
Initialize is the translation initialization function shared by the main program and package.
func LoadTranslations ¶
LoadTranslations loads translation files and sets the locale to the system locale. It should be called by the main program.
func SetLanguage ¶
func SetLanguage(language string)
SetLanguage sets the program's current locale. If the language is not supported, then the default locale is used.
Types ¶
type Translator ¶
Translator is a wrapper over gotext's Locale and provides interface to translate text string and produce translated error
func (*Translator) Errorf ¶
func (t *Translator) Errorf(msgid string, vars ...interface{}) error
Errorf produces an error with a translated error string.
func (*Translator) NErrorf ¶
func (t *Translator) NErrorf(msgid, msgidPlural string, n int, vars ...interface{}) error
NErrorf produces an error with a translated error string in the appropriate plural form.
func (*Translator) NT ¶
func (t *Translator) NT(msgid, msgidPlural string, n int, vars ...interface{}) string
NT translates a text string into the appropriate plural form, based on GNU's gettext library.
func (*Translator) T ¶
func (t *Translator) T(msgid string, vars ...interface{}) string
T translates a text string, based on GNU's gettext library.