Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lingo ¶
type Lingo struct {
// contains filtered or unexported fields
}
Lingo is a translation bundle of all translations by locale, as well as default locale and list of supported locales
func New ¶
New creates the Lingo bundle. `deflt` is the default locale, which is used when the requested locale is not found, and when translations are not found in the requested locale. `path` is the absolute or relative path to the folder of TOML translations. `fs` is either a FileSystem or null, used to locate the path and translation files.
func (*Lingo) TranslationsForLocale ¶
func (l *Lingo) TranslationsForLocale(locale string) Translations
TranslationsForLocale will get the T for specific locale. If no locale is found, returns default T
func (*Lingo) TranslationsForRequest ¶
func (l *Lingo) TranslationsForRequest(r *http.Request) Translations
TranslationsForRequest will get the best matched T for given Request. If no T is found, returns default T
type Locale ¶
Locale is locale value from the Accept-Language header in request
func GetLocales ¶
GetLocales returns supported locales for the given requet
func GetPreferredLocale ¶
GetPreferredLocale return preferred locale for the given reuqest returns error if there is no preferred locale
func ParseLocale ¶
ParseLocale creates a Locale from a locale string
type Translations ¶
type Translations struct {
// contains filtered or unexported fields
}
Translations represents translations map for specific locale