Repository: gohugoio/hugo (language: go)

Issue:
languages.xx.disabled not working with v0.112.0 and later
This works as expected with v0.111.3 and earlier:

```
[languages.es]
languageCode = 'es-ES'
weight = 3
disabled = true
```

With v0.112.0 and later, the site above is published (the `disabled` key is ignored) with this warning:

> WARN  config: languages.es.disabled: custom params on the language top level is deprecated and will be removed in a future release. Put the value below [languages.es.params].





Discussion / hints:
See <https://github.com/gohugoio/hugo/issues/4963#issuecomment-406076190>.

I don't think `languages.xx.disabled` was ever documented, so perhaps this behavior is correct (not a bug).
Workaround: `disableLanguages = ["en']` ... I don't find `language.disabled` in the docs, which is probably why it got lost ...


Fix patch:
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go
index bab15501b7e..86a887155ed 100644
--- a/config/allconfig/allconfig.go
+++ b/config/allconfig/allconfig.go
@@ -274,6 +274,14 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
 		}
 		disabledLangs[lang] = true
 	}
+	for lang, language := range c.Languages {
+		if language.Disabled {
+			disabledLangs[lang] = true
+			if lang == c.DefaultContentLanguage {
+				return fmt.Errorf("cannot disable default content language %q", lang)
+			}
+		}
+	}
 
 	ignoredErrors := make(map[string]bool)
 	for _, err := range c.IgnoreErrors {
diff --git a/langs/config.go b/langs/config.go
index f60ea94a4dd..7cca0f5e7b2 100644
--- a/langs/config.go
+++ b/langs/config.go
@@ -39,6 +39,9 @@ type LanguageConfig struct {
 	// The language weight. When set to a non-zero value, this will
 	// be the main sort criteria for the language.
 	Weight int
+
+	// Set to true to disable this language.
+	Disabled bool
 }
 
 func DecodeConfig(m map[string]any) (map[string]LanguageConfig, error) {


Test patch:
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index 567059e6834..cdac0fbab93 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -1384,3 +1384,30 @@ Home.
 	})
 
 }
+
+func TestLanguagesDisabled(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- hugo.toml --
+[languages]
+[languages.en]
+title = "English Title"
+[languages.sv]
+title = "Swedish Title"
+disabled = true
+-- layouts/index.html --
+Home.
+
+	
+`
+	b := NewIntegrationTestBuilder(
+		IntegrationTestConfig{
+			T:           t,
+			TxtarString: files,
+		},
+	).Build()
+
+	b.Assert(len(b.H.Sites), qt.Equals, 1)
+
+}