mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
8f293a1855
commit
6c2db0dfb0
5 changed files with 17 additions and 5 deletions
|
@ -824,6 +824,7 @@ baseURL = "https://example.com"
|
||||||
disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"]
|
disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"]
|
||||||
[languages]
|
[languages]
|
||||||
[languages.en]
|
[languages.en]
|
||||||
|
languageCode = "en-US"
|
||||||
title = "English Title"
|
title = "English Title"
|
||||||
[languages.en.params]
|
[languages.en.params]
|
||||||
myparam = "enParamValue"
|
myparam = "enParamValue"
|
||||||
|
@ -840,6 +841,7 @@ title: "My English Section"
|
||||||
title: "My Swedish Section"
|
title: "My Swedish Section"
|
||||||
---
|
---
|
||||||
-- layouts/index.html --
|
-- layouts/index.html --
|
||||||
|
LanguageCode: {{ eq site.LanguageCode site.Language.LanguageCode }}|{{ site.Language.LanguageCode }}|
|
||||||
{{ range $i, $e := (slice site .Site) }}
|
{{ 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 }}
|
{{ $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 }}
|
{{ end }}
|
||||||
|
@ -863,10 +865,12 @@ Sections: true|
|
||||||
Param: enParamValue
|
Param: enParamValue
|
||||||
Param: enParamValue
|
Param: enParamValue
|
||||||
IsMultiLingual: true
|
IsMultiLingual: true
|
||||||
|
LanguageCode: true|en-US|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
b.AssertFileContent("public/sv/index.html", `
|
b.AssertFileContent("public/sv/index.html", `
|
||||||
Param: svParamValue
|
Param: svParamValue
|
||||||
|
LanguageCode: true|sv|
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
|
@ -361,10 +361,7 @@ func (s *Site) Config() page.SiteConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) LanguageCode() string {
|
func (s *Site) LanguageCode() string {
|
||||||
if s.conf.LanguageCode != "" {
|
return s.Language().LanguageCode()
|
||||||
return s.conf.LanguageCode
|
|
||||||
}
|
|
||||||
return s.language.Lang
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns all Sites for all languages.
|
// Returns all Sites for all languages.
|
||||||
|
|
|
@ -24,6 +24,9 @@ type LanguageConfig struct {
|
||||||
// The language name, e.g. "English".
|
// The language name, e.g. "English".
|
||||||
LanguageName string
|
LanguageName string
|
||||||
|
|
||||||
|
// The language code, e.g. "en-US".
|
||||||
|
LanguageCode string
|
||||||
|
|
||||||
// The language title. When set, this will
|
// The language title. When set, this will
|
||||||
// override site.Title for this language.
|
// override site.Title for this language.
|
||||||
Title string
|
Title string
|
||||||
|
|
|
@ -102,6 +102,13 @@ func (l *Language) Params() maps.Params {
|
||||||
return l.params
|
return l.params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Language) LanguageCode() string {
|
||||||
|
if l.LanguageConfig.LanguageCode != "" {
|
||||||
|
return l.LanguageConfig.LanguageCode
|
||||||
|
}
|
||||||
|
return l.Lang
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Language) loadLocation(tzStr string) error {
|
func (l *Language) loadLocation(tzStr string) error {
|
||||||
location, err := time.LoadLocation(tzStr)
|
location, err := time.LoadLocation(tzStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -65,6 +65,7 @@ type Site interface {
|
||||||
Title() string
|
Title() string
|
||||||
|
|
||||||
// Returns the configured language code for this Site.
|
// Returns the configured language code for this Site.
|
||||||
|
// Deprecated: Use .Language.LanguageCode instead.
|
||||||
LanguageCode() string
|
LanguageCode() string
|
||||||
|
|
||||||
// Returns the configured copyright information for this Site.
|
// Returns the configured copyright information for this Site.
|
||||||
|
|
Loading…
Reference in a new issue