From f1491c900e83adbf009a0db8497791aeb9bd6357 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Fri, 16 Feb 2024 13:41:59 +0100 Subject: Fix i18n rebuild regression Fixes #12039 --- hugolib/hugo_sites_build.go | 4 +++- hugolib/rebuild_test.go | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 17af2d8d8..17a3f0056 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -790,7 +790,9 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf case files.ComponentFolderI18n: logger.Println("i18n changed", pathInfo.Path()) i18nChanged = true - changes = append(changes, pathInfo) + // It's hard to determine the exact change set of this, + // so be very coarse grained for now. + changes = append(changes, identity.GenghisKhan) default: panic(fmt.Sprintf("unknown component: %q", pathInfo.Component())) } diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go index 9b15fc3e2..06a6083f5 100644 --- a/hugolib/rebuild_test.go +++ b/hugolib/rebuild_test.go @@ -1149,6 +1149,28 @@ Single. b.AssertFileContent("public/index.html", "Home.", "") } +func TestRebuildI18n(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +disableLiveReload = true +-- i18n/en.toml -- +hello = "Hello" +-- layouts/index.html -- +Hello: {{ i18n "hello" }} +` + + b := TestRunning(t, files) + + b.AssertFileContent("public/index.html", "Hello: Hello") + + b.EditFileReplaceAll("i18n/en.toml", "Hello", "Hugo").Build() + + b.AssertFileContent("public/index.html", "Hello: Hugo") +} + func TestRebuildVariationsAssetsSassImport(t *testing.T) { if !htesting.IsCI() { t.Skip("skip CI only") -- cgit v1.2.3