mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 12:03:09 +00: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) },
|
"upper": func(a string) string { return strings.ToUpper(a) },
|
||||||
"urlize": helpers.CurrentPathSpec().URLize,
|
"urlize": helpers.CurrentPathSpec().URLize,
|
||||||
"where": where,
|
"where": where,
|
||||||
"i18n": I18nTranslate,
|
"i18n": i18nTranslate,
|
||||||
"T": I18nTranslate,
|
"T": i18nTranslate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// Logi18nWarnings set to true to print warnings about missing language strings
|
||||||
Logi18nWarnings bool
|
Logi18nWarnings bool
|
||||||
i18nWarningLogger = helpers.NewDistinctFeedbackLogger()
|
i18nWarningLogger = helpers.NewDistinctFeedbackLogger()
|
||||||
currentLanguage *helpers.Language
|
currentLanguage *helpers.Language
|
||||||
|
@ -49,6 +50,7 @@ func SetTranslateLang(language *helpers.Language) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetI18nTfuncs sets the language bundle to be used for i18n.
|
||||||
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||||
translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)}
|
translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)}
|
||||||
defaultContentLanguage := viper.GetString("defaultContentLanguage")
|
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 {
|
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.")
|
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
|
return "", nil
|
||||||
|
|
|
@ -119,7 +119,7 @@ func doTestI18nTranslate(t *testing.T, data map[string][]byte, lang, id string,
|
||||||
SetI18nTfuncs(i18nBundle)
|
SetI18nTfuncs(i18nBundle)
|
||||||
SetTranslateLang(helpers.NewLanguage(lang))
|
SetTranslateLang(helpers.NewLanguage(lang))
|
||||||
|
|
||||||
translated, err := I18nTranslate(id, args)
|
translated, err := i18nTranslate(id, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error translating '%s': %s", id, err)
|
t.Errorf("Error translating '%s': %s", id, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue