diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-05-27 15:44:41 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-05-27 16:56:54 +0200 |
commit | 6c2db0dfb0720c0af6ffabb438e1d2ea8eb909b4 (patch) | |
tree | 6656476fb3702f4043d179bc95e9f69796f6c40e /hugolib | |
parent | 8f293a18557806b5370451c13ea8959e85962c9b (diff) | |
download | hugo-6c2db0dfb0720c0af6ffabb438e1d2ea8eb909b4.tar.gz hugo-6c2db0dfb0720c0af6ffabb438e1d2ea8eb909b4.zip |
Add language.LanguageCode
But keep an alias at Site
Closes #11027
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/config_test.go | 6 | ||||
-rw-r--r-- | hugolib/site_new.go | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 2f9c6e3f6..f742eb862 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -824,6 +824,7 @@ baseURL = "https://example.com" disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"] [languages] [languages.en] +languageCode = "en-US" title = "English Title" [languages.en.params] myparam = "enParamValue" @@ -840,6 +841,7 @@ title: "My English Section" title: "My Swedish Section" --- -- layouts/index.html -- +LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Language.LanguageCode }}| {{ range $i, $e := (slice site .Site) }} {{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}| Author: {{ .Authors }}|BuildDrafts: {{ .BuildDrafts }}|IsMultiLingual: {{ .IsMultiLingual }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }} {{ end }} @@ -863,10 +865,12 @@ Sections: true| Param: enParamValue Param: enParamValue IsMultiLingual: true +LanguageCode: true|en-US| `) b.AssertFileContent("public/sv/index.html", ` -Param: svParamValue +Param: svParamValue +LanguageCode: true|sv| `) diff --git a/hugolib/site_new.go b/hugolib/site_new.go index e5398ba8d..4b3a28bdd 100644 --- a/hugolib/site_new.go +++ b/hugolib/site_new.go @@ -361,10 +361,7 @@ func (s *Site) Config() page.SiteConfig { } func (s *Site) LanguageCode() string { - if s.conf.LanguageCode != "" { - return s.conf.LanguageCode - } - return s.language.Lang + return s.Language().LanguageCode() } // Returns all Sites for all languages. |