publicSettings

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2017 License: MIT Imports: 14 Imported by: 96

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flag

func Flag(languageCode string, parent bool) string

Flag reads the language's country code and return the country's flag if national true or the international flag for the language

func GetDefaultLanguage

func GetDefaultLanguage() string

GetDefaultLanguage : returns the default language from config

func GetDefaultTfunc

func GetDefaultTfunc() (i18n.TranslateFunc, error)

GetDefaultTfunc : Gets T func from default language

func GetMascotFromRequest

func GetMascotFromRequest(c *gin.Context) string

GetMascotFromRequest : Gets the user selected theme from the request

func GetMascotUrlFromRequest

func GetMascotUrlFromRequest(c *gin.Context) string

GetMascotUrlFromRequest : Get the user selected mascot url from the request. Returns an empty string if not set.

func GetParentTag

func GetParentTag(languageTag string) glang.Tag

GetParentTag returns the highest parent of a language (e.g. fr-fr -> fr)

func GetTfuncAndLanguageFromRequest

func GetTfuncAndLanguageFromRequest(c *gin.Context) (T i18n.TranslateFunc, Tlang *language.Language)

GetTfuncAndLanguageFromRequest : Gets the T func and chosen language from the request

func GetThemeFromRequest

func GetThemeFromRequest(c *gin.Context) string

GetThemeFromRequest : Gets the user selected theme from the request

func InitI18n

func InitI18n(conf config.I18nConfig, retriever UserRetriever) error

InitI18n : Initialize the languages translation

func TfuncAndLanguageWithFallback

func TfuncAndLanguageWithFallback(language string, languages ...string) (i18n.TranslateFunc, *language.Language, error)

TfuncAndLanguageWithFallback : When go-i18n finds a language with >0 translations, it uses it as the Tfunc However, if said language has a missing translation, it won't fallback to the "main" language

func Translate

func Translate(languageCode string, to string) string

Translate accepts a languageCode in string and translate the language to the language from the language code in to

Types

type Language

type Language struct {
	Name string
	Code string
	Tag  string
}

func (*Language) Flag

func (lang *Language) Flag(national bool) string

Flag reads the language's country code and return the country's flag if national true or the international flag for the language

func (*Language) Translate

func (lang *Language) Translate(languageCode template.HTML) string

Translate accepts a languageCode in string and translate the language to the language from the language code

type Languages

type Languages []Language

func GetAvailableLanguages

func GetAvailableLanguages() Languages

GetAvailableLanguages : Get languages available on the website, languages are parsed once at runtime

func ParseLanguages

func ParseLanguages(codes []string) Languages

ParseLanguages takes a list of language codes and convert them in languages object

func (Languages) Exist

func (langs Languages) Exist(name string) bool

Exist evaluate if a language exists or not (language code or language name)

type TemplateTfunc

type TemplateTfunc func(string, ...interface{}) template.HTML

TemplateTfunc : T func used in template

func GetTfuncFromRequest

func GetTfuncFromRequest(c *gin.Context) TemplateTfunc

GetTfuncFromRequest : Gets the T func from the request

type UserRetriever

type UserRetriever interface {
	RetrieveCurrentUser(c *gin.Context) (*models.User, error)
}

UserRetriever : this interface is required to prevent a cyclic import between the languages and userService package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL