summaryrefslogtreecommitdiffstats
path: root/langs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-05 09:57:58 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-05 16:11:11 +0200
commit658e11ebaa94de219f941699d119a97a18301eea (patch)
tree76330777138b792bac1dfcf05e9948d9f5839bcc /langs
parente0a882fd3b9825dc9a95b83d72fc330dcbbbcce9 (diff)
Localize all the GroupBy*Date methods
Fixes #9745
Diffstat (limited to 'langs')
-rw-r--r--langs/language.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/langs/language.go b/langs/language.go
index 3bb131be1..0df2914a1 100644
--- a/langs/language.go
+++ b/langs/language.go
@@ -21,6 +21,7 @@ import (
"github.com/pkg/errors"
+ "github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/locales"
@@ -77,7 +78,8 @@ type Language struct {
// Used for date formatting etc. We don't want these exported to the
// templates.
// TODO(bep) do the same for some of the others.
- translator locales.Translator
+ translator locales.Translator
+ timeFormatter htime.TimeFormatter
location *time.Location
@@ -113,9 +115,10 @@ func NewLanguage(lang string, cfg config.Provider) *Language {
Lang: lang,
ContentDir: cfg.GetString("contentDir"),
Cfg: cfg, LocalCfg: localCfg,
- Provider: compositeConfig,
- params: params,
- translator: translator,
+ Provider: compositeConfig,
+ params: params,
+ translator: translator,
+ timeFormatter: htime.NewTimeFormatter(translator),
}
if err := l.loadLocation(cfg.GetString("timeZone")); err != nil {
@@ -260,6 +263,10 @@ func (l *Language) IsSet(key string) bool {
// Internal access to unexported Language fields.
// This construct is to prevent them from leaking to the templates.
+func GetTimeFormatter(l *Language) htime.TimeFormatter {
+ return l.timeFormatter
+}
+
func GetTranslator(l *Language) locales.Translator {
return l.translator
}