diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-07-26 18:28:57 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-07-27 19:02:48 +0200 |
commit | a57dda854b5efd3429af5f0b1564fc9d9d5439b9 (patch) | |
tree | 8e01442c7c43cc5bef5c9d5dbfdb3e0132736efe /hugolib/dates_test.go | |
parent | f9afba933579de07d2d2e36a457895ec5f1b7f01 (diff) | |
download | hugo-a57dda854b5efd3429af5f0b1564fc9d9d5439b9.tar.gz hugo-a57dda854b5efd3429af5f0b1564fc9d9d5439b9.zip |
Localize time.Format
Fixes #8797
Diffstat (limited to 'hugolib/dates_test.go')
-rw-r--r-- | hugolib/dates_test.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/hugolib/dates_test.go b/hugolib/dates_test.go new file mode 100644 index 000000000..fa03bc16b --- /dev/null +++ b/hugolib/dates_test.go @@ -0,0 +1,56 @@ +// Copyright 2021 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 hugolib + +import ( + "testing" +) + +func TestDateFormatMultilingual(t *testing.T) { + b := newTestSitesBuilder(t) + b.WithConfigFile("toml", ` +baseURL = "https://example.org" + +defaultContentLanguage = "en" +defaultContentLanguageInSubDir = true + +[languages] +[languages.en] +weight=10 +[languages.nn] +weight=20 + +`) + + pageWithDate := `--- +title: Page +date: 2021-07-18 +--- +` + + b.WithContent( + "_index.en.md", pageWithDate, + "_index.nn.md", pageWithDate, + ) + + b.WithTemplatesAdded("index.html", ` +Date: {{ .Date | time.Format ":date_long" }} + `) + + b.Build(BuildCfg{}) + + b.AssertFileContent("public/en/index.html", `Date: July 18, 2021`) + b.AssertFileContent("public/nn/index.html", `Date: 18. juli 2021`) + +} |