Language
Syntax
Returns
The Language method on a Page object returns the language object for the given page. The language object is derived from the language definition in the site configuration.
You can also use the Language method on a Site object. See details.
Methods
The examples below assume the following in the site configuration:
languages:
de:
languageCode: de-DE
languageDirection: ltr
languageName: Deutsch
weight: 2
[languages]
[languages.de]
languageCode = 'de-DE'
languageDirection = 'ltr'
languageName = 'Deutsch'
weight = 2
{
"languages": {
"de": {
"languageCode": "de-DE",
"languageDirection": "ltr",
"languageName": "Deutsch",
"weight": 2
}
}
}
IsDefault
New in v0.153.0(bool) Reports whether this is the default language object as defined by the defaultContentLanguage setting in the site configuration.
{{ .Language.IsDefault }} → trueLang
(string) The language tag as defined by RFC 5646. This is the lower cased key from the site configuration.
{{ .Language.Lang }} → deLanguageCode
(string) The language code from the site configuration. Falls back to Lang if not defined.
{{ .Language.LanguageCode }} → de-DELanguageDirection
(string) The language direction from the site configuration, either ltr or rtl.
{{ .Language.LanguageDirection }} → ltrLanguageName
(string) The language name from the site configuration.
{{ .Language.LanguageName }} → DeutschName
(string) The language tag as defined by RFC 5646. This is the lower cased key used in the site configuration. This is an alias for Lang.
{{ .Site.Language.Name }} → deWeight
(int) The language weight from the site configuration which determines its order in the slice of languages returned by the Languages method on a Site object.
{{ .Language.Weight }} → 2