Fill in the missing translations

Hi Hugo community,

According to the official website document, the purpose of lang.Merge is to combine pages in other languages, so that untranslated content can also be presented in other languages. For example, if the current Site Language is German, and a certain Page has only English version, then the lang.Merge function can be used to present English content.

But it’s confusing to use!
Any Idea how could I fill in the missing translations here?

<select id="select-language" onchange="location = this.value;" class="language-selector">
  {{ $siteLanguages := .Site.Languages}}
  {{ $pageLang := .Page.Lang}}
  {{ range .Page.AllTranslations }}
    {{ $translation := .}}
    {{ range $siteLanguages }}
      {{ if eq $translation.Lang .Lang }}
        {{ if eq $pageLang .Lang}}
          <option id="{{ $translation.Language }}" value="{{ $translation.URL }}" selected>{{ .LanguageName }}</option>
        {{ else }}
          <option id="{{ $translation.Language }}" value="{{ $translation.URL }}">{{ .LanguageName }}</option>
        {{ end }}
      {{ end }}
    {{ end }}
  {{ end }}
</select>

Your goal is unclear.

Assuming this site configuration:

defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true

[languages.en]
weight = 1
languageName = 'English'
contentDir = 'content/en'
[languages.es]
weight = 2
languageName = 'Español'
contentDir = 'content/es'
[languages.fr]
weight = 3
languageName = 'Français'
contentDir = 'content/fr'

And assuming this content:

content/
├── en/
│   ├── foo.md
│   └── _index.md
├── es/
│   ├── foo.md
│   └── _index.md
└── fr/
    └── _index.md

When visiting http://localhost:1313/en/foo/

  • Should “French” appear in the <select> list?
  • If yes, which page should be shown when the user selects “French”?