diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-27 15:44:41 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-27 16:56:54 +0200 |
commit | 6c2db0dfb0720c0af6ffabb438e1d2ea8eb909b4 (patch) | |
tree | 6656476fb3702f4043d179bc95e9f69796f6c40e /langs | |
parent | 8f293a18557806b5370451c13ea8959e85962c9b (diff) |
Add language.LanguageCode
But keep an alias at Site
Closes #11027
Diffstat (limited to 'langs')
-rw-r--r-- | langs/config.go | 3 | ||||
-rw-r--r-- | langs/language.go | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/langs/config.go b/langs/config.go index 3c7278388..15c0bedbc 100644 --- a/langs/config.go +++ b/langs/config.go @@ -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 diff --git a/langs/language.go b/langs/language.go index 232331cae..a1b8f4326 100644 --- a/langs/language.go +++ b/langs/language.go @@ -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 { |