tpl/time: Fix locale-specific month abbreviations

Closes #14948
This commit is contained in:
Joe Mooring
2026-05-26 11:49:00 -07:00
committed by Bjørn Erik Pedersen
parent 076dfe13d0
commit ea8b48af64
3 changed files with 56 additions and 5 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ require (
github.com/bep/goat v0.5.0
github.com/bep/godartsass/v2 v2.5.0
github.com/bep/golibsass v1.2.0
github.com/bep/golocales v0.1.0
github.com/bep/golocales v0.2.0
github.com/bep/goportabletext v0.2.0
github.com/bep/helpers v0.12.0
github.com/bep/imagemeta v0.17.2
+2 -4
View File
@@ -158,8 +158,8 @@ github.com/bep/godartsass/v2 v2.5.0 h1:tKRvwVdyjCIr48qgtLa4gHEdtRkPF8H1OeEhJAEv7
github.com/bep/godartsass/v2 v2.5.0/go.mod h1:rjsi1YSXAl/UbsGL85RLDEjRKdIKUlMQHr6ChUNYOFU=
github.com/bep/golibsass v1.2.0 h1:nyZUkKP/0psr8nT6GR2cnmt99xS93Ji82ZD9AgOK6VI=
github.com/bep/golibsass v1.2.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA=
github.com/bep/golocales v0.1.0 h1:rjWf1S4basIje+G+je5WMW8G+yzaoz4gEDFolrFVdvA=
github.com/bep/golocales v0.1.0/go.mod h1:Hl78nje8mNL3LzLeJvYN9NsIZgyFJGrGfvgO9r1+mwE=
github.com/bep/golocales v0.2.0 h1:4H1H5UPw3ainpj5zykeEfiMRQngyaIC/t+I4Dvn+fvE=
github.com/bep/golocales v0.2.0/go.mod h1:Hl78nje8mNL3LzLeJvYN9NsIZgyFJGrGfvgO9r1+mwE=
github.com/bep/goportabletext v0.2.0 h1:CZ9f8jADBWqHwBymQiJJPCTSV/tHSA+PYzlUf86Yze0=
github.com/bep/goportabletext v0.2.0/go.mod h1:xDeA5+qcgKzJq6Q6XjAiBKtxLD3Yn7f6XP4joD3J3qU=
github.com/bep/helpers v0.12.0 h1:tD6V2DQW0B+FUynF2etR/106S/TO9akm+vA/Hk24GxY=
@@ -502,8 +502,6 @@ github.com/tdewolff/parse/v2 v2.8.12/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLB
github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/tdewolff/test v1.0.12 h1:7F21DqIajswxuche0geHdrUZRCWE4oko4b7bcmkkrxk=
github.com/tdewolff/test v1.0.12/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
github.com/tetratelabs/wazero v1.11.1-0.20260521072212-475a1f8f0dc3 h1:0Jpp+tPkvALC9hcZUYOj/6yWYvUIV/kKoxRDj0a6zk4=
github.com/tetratelabs/wazero v1.11.1-0.20260521072212-475a1f8f0dc3/go.mod h1:LvKtzl2RqO4gyF27BiXU+nKAjcV8f38U+kP/q2vgxh0=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
+53
View File
@@ -0,0 +1,53 @@
// Copyright 2017 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package time_test
import (
"testing"
"github.com/gohugoio/hugo/hugolib"
)
// See issue 14948.
func TestTimeFormatMonthAbbreviationsEnGB(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
locale = 'en-GB'
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- layouts/home.html --
{{ $dates := slice
"2025-01-17T10:42:00-08:00"
"2025-02-17T10:42:00-08:00"
"2025-03-17T10:42:00-07:00"
"2025-04-17T10:42:00-07:00"
"2025-05-17T10:42:00-07:00"
"2025-06-17T10:42:00-07:00"
"2025-07-17T10:42:00-07:00"
"2025-08-17T10:42:00-07:00"
"2025-09-17T10:42:00-07:00"
"2025-10-17T10:42:00-07:00"
"2025-11-17T10:42:00-08:00"
"2025-12-17T10:42:00-08:00"
}}
{{- range $dates }}
{{- time.Format "Jan" . }}|
{{- end }}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sept|Oct|Nov|Dec|")
}