mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -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"]
|
||||
[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|
|
||||
|
||||
`)
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -24,6 +24,9 @@ type LanguageConfig struct {
|
|||
// The language name, e.g. "English".
|
||||
LanguageName string
|
||||
|
||||
// The language code, e.g. "en-US".
|
||||
LanguageCode string
|
||||
|
||||
// The language title. When set, this will
|
||||
// override site.Title for this language.
|
||||
Title string
|
||||
|
|
|
@ -102,6 +102,13 @@ func (l *Language) Params() maps.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 {
|
||||
location, err := time.LoadLocation(tzStr)
|
||||
if err != nil {
|
||||
|
|
|
@ -65,6 +65,7 @@ type Site interface {
|
|||
Title() string
|
||||
|
||||
// Returns the configured language code for this Site.
|
||||
// Deprecated: Use .Language.LanguageCode instead.
|
||||
LanguageCode() string
|
||||
|
||||
// Returns the configured copyright information for this Site.
|
||||
|
|
Loading…
Reference in a new issue