{{/*

  Returns the fallback page of this page, if it has one.
  A fallback page, is a page in the default site language
  that has been mounted under this locale as a fallback
  when this locale is missing a translation.

*/ -}}

{{ $result := false -}}

{{ if and .Site.IsMultiLingual .File -}}
  {{ $defaultLang := .Site.Sites.Default.Language.Lang -}}

  {{ $resultsArray := where .Translations "Lang" $defaultLang -}}
  {{ $defaultLangPage := index $resultsArray 0 -}}
  {{ if and $defaultLangPage
            $defaultLangPage.File
            (eq .File.Filename $defaultLangPage.File.Filename)
  -}}
    {{ $result = $defaultLangPage -}}
  {{ end -}}
{{ end -}}

{{ return $result -}}
