]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix i18n rebuild regression
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 16 Feb 2024 12:41:59 +0000 (13:41 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 16 Feb 2024 15:17:57 +0000 (16:17 +0100)
Fixes #12039

hugolib/hugo_sites_build.go
hugolib/rebuild_test.go

index 17af2d8d8dc0c2562a6d897a1308545d9063d766..17a3f00563ababcf92af7475c46adf3946933700 100644 (file)
@@ -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()))
                }
index 9b15fc3e29eb22ff868c8aa0c4fc8780f495818f..06a6083f54615d56fb5b444f7672a55ec90157e6 100644 (file)
@@ -1149,6 +1149,28 @@ Single.
        b.AssertFileContent("public/index.html", "Home.", "<style>body {\n\tbackground: blue;\n}</style>")
 }
 
+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")