Skip to content

langs: Add IsDefault field to Language struct #13855

@jmooring

Description

@jmooring

While ranging through .Page.AllTranslations or .Page.Translations, it would be useful to know if the current language is the defaultContentLanguage. Those methods return the page collection sorted by language weight; the first may or may not be the default.

This would be a convenience method so that you could do this:

{{ range .AllTranslations }}
  {{ if .Language.IsDefault }}
     ...
  {{ end }}
{{ end }}

instead of this:

{{ range .AllTranslations }}
  {{ if eq .Site .Sites.Default }}
     ...
  {{ end }}
{{ end }}

The first is, at least to me, easier to understand

If we do something like this, the API may depend on pending dimensions work.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions