Documentation ¶
Overview ¶
Package i18n is for app Internationalization and Localization.
Index ¶
- Variables
- func Count() int
- func GetDescriptionByIndex(index int) string
- func GetDescriptionByLang(lang string) string
- func GetLangByIndex(index int) string
- func IndexLang(lang string) int
- func IsExist(lang string) bool
- func IsExistSimilar(lang string) (string, bool)
- func ListLangDescs() []string
- func ListLangs() []string
- func ReloadLangs(langs ...string) error
- func SetDefaultLang(lang string)
- func SetMessage(lang string, localeFile interface{}, otherLocaleFiles ...interface{}) error
- func SetMessageWithDesc(lang, langDesc string, localeFile interface{}, otherLocaleFiles ...interface{}) error
- func Tr(lang, format string, args ...interface{}) string
- type Locale
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrLangAlreadyExist throwed when language is already exists. ErrLangAlreadyExist = errors.New("lang already exists") )
Functions ¶
func GetDescriptionByIndex ¶
func GetDescriptionByLang ¶
func GetLangByIndex ¶
GetLangByIndex return language by given index.
func IsExistSimilar ¶
IsExistSimilar returns true if the language, or something similar exists (e.g. en-US maps to en). it returns the found name and whether it was able to match something. - PATCH by @j-lenoch.
func ListLangDescs ¶
func ListLangDescs() []string
func SetDefaultLang ¶
func SetDefaultLang(lang string)
SetDefaultLang sets default language which is a indicator that when target language is not found, try find in default language again.
func SetMessage ¶
SetMessage sets the message file for localization.
func SetMessageWithDesc ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.