import (
"testing"
+ qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/hugolib"
)
b.AssertFileContent("public/index.html", `description: This is a description from i18n.|`)
}
+
+// See issue #14061
+func TestI18nReservedKeyScalar(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['home','page','rss','section','sitemap','taxonomy','term']
+-- i18n/en.toml --
+a = 'a translated'
+description = 'description translated'
+b = 'b translated'
+
+`
+
+ b, err := hugolib.TestE(t, files)
+
+ b.Assert(err, qt.IsNotNil)
+ b.Assert(err.Error(), qt.Contains, "failed to load translations: reserved keys [description] mixed with unreserved keys [a b]: see the lang.Translate documentation for a list of reserved keys")
+}
return nil
}
}
- return errWithFileContext(fmt.Errorf("failed to load translations: %w", err), r)
+ var guidance string
+ if strings.Contains(err.Error(), "mixed with unreserved keys") {
+ guidance = ": see the lang.Translate documentation for a list of reserved keys"
+ }
+ return errWithFileContext(fmt.Errorf("failed to load translations: %w%s", err, guidance), r)
}
return nil