mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl: Golint fixes
This commit is contained in:
parent
d4830fc4fd
commit
07eb3a50c7
3 changed files with 6 additions and 4 deletions
|
@ -2051,7 +2051,7 @@ func initFuncMap() {
|
|||
"upper": func(a string) string { return strings.ToUpper(a) },
|
||||
"urlize": helpers.CurrentPathSpec().URLize,
|
||||
"where": where,
|
||||
"i18n": I18nTranslate,
|
||||
"T": I18nTranslate,
|
||||
"i18n": i18nTranslate,
|
||||
"T": i18nTranslate,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Logi18nWarnings set to true to print warnings about missing language strings
|
||||
Logi18nWarnings bool
|
||||
i18nWarningLogger = helpers.NewDistinctFeedbackLogger()
|
||||
currentLanguage *helpers.Language
|
||||
|
@ -49,6 +50,7 @@ func SetTranslateLang(language *helpers.Language) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetI18nTfuncs sets the language bundle to be used for i18n.
|
||||
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||
translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)}
|
||||
defaultContentLanguage := viper.GetString("defaultContentLanguage")
|
||||
|
@ -89,7 +91,7 @@ func SetI18nTfuncs(bndl *bundle.Bundle) {
|
|||
}
|
||||
}
|
||||
|
||||
func I18nTranslate(id string, args ...interface{}) (string, error) {
|
||||
func i18nTranslate(id string, args ...interface{}) (string, error) {
|
||||
if translator == nil || translator.current == nil {
|
||||
helpers.DistinctErrorLog.Printf("i18n not initialized, check that you have language file (in i18n) that matches the site language or the default language.")
|
||||
return "", nil
|
||||
|
|
|
@ -119,7 +119,7 @@ func doTestI18nTranslate(t *testing.T, data map[string][]byte, lang, id string,
|
|||
SetI18nTfuncs(i18nBundle)
|
||||
SetTranslateLang(helpers.NewLanguage(lang))
|
||||
|
||||
translated, err := I18nTranslate(id, args)
|
||||
translated, err := i18nTranslate(id, args)
|
||||
if err != nil {
|
||||
t.Errorf("Error translating '%s': %s", id, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue