"upper": func(a string) string { return strings.ToUpper(a) },
"urlize": helpers.CurrentPathSpec().URLize,
"where": where,
- "i18n": I18nTranslate,
- "T": I18nTranslate,
+ "i18n": i18nTranslate,
+ "T": i18nTranslate,
}
}
)
var (
+ // Logi18nWarnings set to true to print warnings about missing language strings
Logi18nWarnings bool
i18nWarningLogger = helpers.NewDistinctFeedbackLogger()
currentLanguage *helpers.Language
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")
}
}
-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
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)
}